Re: Getting Autoincrement ID in ADO.NET
- From: tascienu@xxxxxxxxxxxx
- Date: 11 Sep 2005 08:17:13 -0700
But really no one has answered my question as far. I am moving to
ADO.NET from ADO. And i just want to do the same thing i was doig in
ADO, but using the new technology. New technologies should be able to
do what Old technology did (easily), and even do it better (Am I wrong
here?). THEY SAID THAT .NET WILL CUT OUR DEVELOPMENT TIME. SO, I WANT
TO SEE THAT.
I have found a partial solution using ExecuteScalar.
CmdConn.ExecuteScalar("INSERT INTO tblCustomers(Name)VALUES('j. smith')
; SELECT @@IDENTITY")
But when I am doing my inserts, i don't usually use execute. I do
DataAdapter.Update( Dataset );
In ADO, I did this easily:
recordSet rs
rs.AddNew
rs("Name")="J. Smith"
rs.UpdateBatch()
NewID = rs("ID").value
there you go. 3 lines of code, and you are there. Now, I don't mean to
say that ADO.NET is bad. I think it's better. I just need to learn the
new way to do the same thing. As I am migrating my code, I usually do
this:
SQLDataAdapter da
Dataset ds
Datarow dr = ds.Tables(0).NewRow
dr("Name")="J. Smith"
da.Update(ds)
NewID = dr("ID") <-- Unlike in ADO, this one contains NOTHING.
so, I need some pointers as to how i could accomplish this... Is my
question clear ???
.
- Follow-Ups:
- Re: Getting Autoincrement ID in ADO.NET
- From: William \(Bill\) Vaughn
- Re: Getting Autoincrement ID in ADO.NET
- References:
- Getting Autoincrement ID in ADO.NET
- From: tascienu
- Re: Getting Autoincrement ID in ADO.NET
- From: William \(Bill\) Vaughn
- Re: Getting Autoincrement ID in ADO.NET
- From: Bob
- Re: Getting Autoincrement ID in ADO.NET
- From: William \(Bill\) Vaughn
- Getting Autoincrement ID in ADO.NET
- Prev by Date: Re: Storing images
- Next by Date: Connection Time Out
- Previous by thread: Re: Getting Autoincrement ID in ADO.NET
- Next by thread: Re: Getting Autoincrement ID in ADO.NET
- Index(es):
Relevant Pages
|
Loading