I have created a form to insert data into Expenses table. when i'm trying to insert data i got below error.
Attribute ExpensesId in AppModule.ExpensesView1 is required.
I have a Before Insert Trigger to insert ExpensesId to the table. so i don't need to add ExpensesId manually.
how could i resolve this error ?
in this case set the ADF BC type of the expenseId attribute to DBSequence so the framework knows that this is taken care of
Frank
Related
In model project.task I create many2many field x_something linked to another model.
So, in this relation table there is a field id from project.task and another model.
And in another field of project.task I wanna write a function in compute section and in this function I wanna insert a record into this relation table by:
self.env.cr.execute( "INSERT INTO x_table_rel VALUES (value_a,value_b)" )
values are inserted but I don't see connection in odoo, it's blank.
What did I miss?
Will you please post the code you're trying to work with?
Odoo has a system for creating related tables.
in each class declare
related_class_id= fields.Many2many('related.class','related_table_name', 'current_class_id', 'related_class_id')
then in one of the classes set the related_class_id.
This should set the relationship.
I am trying to view data in grid view in asp.net page.I am using oracle databse.I Placed a grid view controller in page and I am trying to bind it with oracle database using datasource wizard. In wizard I chose SQL source, gave connection string. Now i choose a table then it gave query like:
Select * from [table_name]
When I test the query It is giving error like:
There was an error in executing query. Please check the syntax of the command and if present,the type and the values of the parameters and ensure they are correct. ORA-00903: Invalid table name.
The table name is enclosing in square braces. How to get rid of this.
You cann't use [table_name] you need to use table_name only.
It is ok in sql Server [table_name] but not in oracle.
So you need to use like this
Select * from table_name
I 'm working on an ASP.NET Dynamic Data Entities Web Application.
When trying to insert a new entry in one of the tables, with some value in the column_name field, I get the following message :
Cannot insert the value NULL into column 'column_name', table 'DATABASE.dbo.table_name'; column does not allow nulls. INSERT fails.
The column properties are :
Entity Key : True
Nullable : False
Type : String
I believe Dynamic Data is trying to send null value to entity framework for some reason, but I don't know which.
Do you know why Dynamic Data is behaving that way ?
Or have you any idea how to debug the insert process ?
Thanks
I found where the problem come from. A table from the database the model is based contains a trigger. For some reason the model makes an association between the two tables involved in the trigger.
I'm unable to retrieve the latest inserted id from my SQL Server 2000 db using a typed dataset in asp.NET
I have created a tableadapter and I ticked the "Refresh datatable" and "Generate Insert, Update and Delete statements". This auto-generates the Fill and GetData methods, and the Insert, Update, Select and Delete statements.
I have tried every possible solution in this thread
http://forums.asp.net/t/990365.aspx
but I'm still unsuccesfull, it always returns 1(=number of affected rows).
I do not want to create a seperate insert method as the auto-generated insertCommand perfectly suits my needs.
As suggested in the thread above, I have tried to update the InsertCommand SQL syntax to add SELECT SCOPY_IDENTITY() or something similar, I have tried to add a parameter of type ReturnValue, but all I get is the number of affected rows.
Does anyone has a different take on this?
Thanks in advance!
Stijn
I decided to give up, I can't afford to waste any more time on this.
I use the Insert statement after which I do a select MAX(id) query to hget the insert ID
If anyone should have a solution, I'll be glad to read it here
Thanks
Stijn
I successfully found a way to get the incremental id after insert using my table adapter.
My approach is a little different, I'm using a Store procedure to make the insert, so my insert command has all the values but the ID, I made the sp return the ID just calling:
SET #ID=SCOPE_IDENTITY()
and then
COMMIT TRAN
and last line will be
RETURN #ID
Then I searched my table adapter parameters for InsertCommand and set the #RETURNVALUE to the column of the incremental ID of the table, so when it's executed automatically put the return value on the id field.
Hope this help
You need to tell your table's table-adapter to refresh the
data-table after update/insert operation.
This is how you can do that.
Open the properties of TableAdapter -> Default Select Query -> Advnaced options. and Check the option of Refresh the data table. Save the adapter now. Now when you call update on table-adapter, the data-table will be updated [refreshed] after the update/insert operation and will reflect the latest values from database table. if the primary-key or any coloumn is set to auto-increment, the data-table will have those latest value post recent update.
Now you can Call the update as TableAdapterObj.Update(ds.dataTable);
Read latest values from the DataTable(ds.dataTable) coloumns and assign respective values into the child table before update/insert. This will work exactly the way you want.
alt text http://ruchitsurati.net/files/tds1.png
I have a table which links to another table in the ASP.NET membership schema.
Problem is, all the PKs for the ASP.NET tables are uniqueidentifier so mine has to be too. When I add a SqlDatasource and call its Insert() method, I get the following error:
Cannot insert the value NULL into column 'DiscountCode', table 'CreamDb.dbo.CustomInfo1'; column does not allow nulls. INSERT fails.
The statement has been terminated.
The uniqueidentifier is also treated as an object (its data type), but there is no Guid data type. I had this problem before, but the schema was much simpler so I could fix it.
How can I go about fixing this? If I get rid of the data type part in the markup (so just leave the field/parameter name but not the data type stuff), I get another error so that is not possible.
Thanks
What do you mean by "there is no Guid data type"? What's wrong with System.Guid? Can't you just use Guid.NewGuid(), set the field appropriately, and do the insert?
EDIT: Just to give a bit more meat: attach an event handler to the Inserting event, and populate the field then, via the DbCommand returned by SqlDataSourceCommandEventArgs.Command. Or change the SQL used by the INSERT command to ask the database to populate the GUID field for you.
A popullar approach when dealing with references to the ASP.NET Membership Provider's data is, instead of keeping a proper foreign key to the GUIDs, instead store something like the LoweredUserName in your table. Then, use the Membership Provider's API to interact with the object you need. In some cases, you need an ObjectDataSource abstraction layer to accomplish CRUD scenarios.
Set the default value of the column in SQL Sever to "newid()".
Asp.net won't send the value, and the field will get a new guid.