Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inserting a new record via OleDbCommand
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00693070
Message ID:
00693302
Views:
26
>Now, having done that, is there an easy way to get the new ID that was generated for this new record?

You can do SELECT MAX(iID)....but it is not a good idea in a multi-user environment. The best thing is to pre-fetch the iId.

>>It is very strange. This should not fail unless there are some issues accessing SP using OLE DB provider. To prove this, can you just put
RETURN 9999
as the first line of NewId() SP?
>>
>
>Your question made me look closely at my test tables. I was assuming the NewID() function was causing the problems since I tested it on another table that didn't use it, and it worked just fine. In fact, it's the RI code that is causing the problem (surprise, surprise..."trigger failed" should have given me a clue ;-) ). It seems the RI code we use (which is based on the code from Steve Sawyer - the "Effective Techniques" book). It's using some commands that aren't supported in the OLE-DB provider. Specifically, RELEASE and SET ANSI. #DEFINE is also (supposedly) not supported, but that works inside of NewID(). As soon as I removed the Insert trigger, my .NET code worked.
>
>Now, having done that, is there an easy way to get the new ID that was generated for this new record?
- Jayesh
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform