I'm using an access database for my website and have been creating table adapters as per the Data Access tutorials.
However I can't work out how to return a new record's ID after inserting it since access won't accept multiple statements. I have a query in the tableadapter which inserts the new record with default values. Then plan would then be to get the ID of the new record and used that to update the related tables.
I've tried created a new query in the table adapter of SELECT ......IDENTITY as NEWID to return the most recent ID but this does not seem to work.
I have seen posts suggesting it can be done using a partial class but I can't see any that fit my situation and I'm still quite new to this.
Any help is much appreciated
hello all,i have a strange problem.i have a datagrid that has a hidden html input which is set as ru...
By orister
I have a gridview-detailsview arrangment and in the detailsview i have a custom <asp:TemplateFiel...
By decays
I have the standard CSS/XHTML layout -- div container/left/right/footerWhen I place the following co...
By flippin_alias
// // Summary: // Adds a new Out System.Data.Common.DbParameter object to the given command. // // P...
By anonymous
Hello,I am using Visual Studio 2005, C#. In a FormView InsertTemplate the textbox's are databound. ...
By genem, 3 Comments
why its not work?selectident_current("table1")as imgselectident_current("table2")as artinsert into t...
By royroy7, 1 Comments
If this is not relevant to state/session, I apologize for posting in the wrong forum.I have a web ap...
By christianson, 1 Comments
command.Parameters.Add("@Account_DisplayName",SqlDbType.VarChar, 25).Direction =ParameterDirection.I...
By monolithx, 3 Comments
hi iam using sybase 11.0.3.3 ,In my sybase i cant use identity .If i used first time the values are ...
By nthillaiarasu, 1 Comments
I haven't used table adapters with Access, but I suspect that the way to do this is to run some SQL to Select ......Identity in the ObjectDataSource's Inserted event. Hopefully the connection will still be open at this point, otherwise it won't work.
mikesdotnetting | Sun, 06 Jan 2008 09:48:00 GMT |
Thanks. Any ideas or pointers how I can get that working?
nevets2001uk2 | Sun, 06 Jan 2008 09:49:00 GMT |
Hi
Not a direct answer -- But can you lookhttp://www.experts-exchange.com/Databases/MS_Access/Q_21752215.html
andhttp://support.microsoft.com/default.aspx/kb/232144
They are not .NET related, but i am sure you can port the code from ADODB to ADO.NET.
Hope it helps to some extent.
VJ
vijayvrr_2001 | Sun, 06 Jan 2008 09:50:00 GMT |
Having looked at it a bit more closely, I don't think you can use the Inserted event after all. It seems that this is the way to do it:
http://groups.archivesat.com/Access_Databases_and_AccessDataSource_Control/thread382893.htm
http://www.redmountainsw.com/wordpress/archives/returning-identity-column-of-autoincrement-fields
mikesdotnetting | Sun, 06 Jan 2008 09:51:00 GMT |
After a bit more investigation I found an article that suggested a solution... I followed it through and ended up with the following code in a code file.
It looks similar to the suggestions from above but I can't work out how I use this now that I've written it. The insert query is called from the codebehind from one of my pages and debugging it, it seems it does not touch this partial class.
nevets2001uk2 | Sun, 06 Jan 2008 09:52:00 GMT |