Re: VS.2005 c# Autonumber via Access with @@IDENTITY Failing
- From: "Frank Hickman [MVP]" <fhickman3_NOSP@xxxxxxxxxxxxxxx>
- Date: Wed, 25 Jan 2006 13:20:11 -0500
"Michael Slattery" <sncsoftware@xxxxxxxxxxxxxxxx> wrote in message
news:268F16D4-FFCC-4937-93B1-ACA00B5BC547@xxxxxxxxxxxxxxxx
> I'm using VS 2005 C#...
>
> Drop Access DB into Project, creates DataSet/DataTable Adapters....
>
> First Question? Is this ADO.NET or something else for the data access?
>
> Second Question? How do I get the autonumber generated during an insert
> from
> these autogenerated tableadapters?
>
> For Example..
>
> //Add to DB
> Database.dbDataSetTableAdapters.tblPeopleTableAdapter ta = new
> Database.dbDataSetTableAdapters.tblPeopleTableAdapter();
>
> ta.Insert(this._lastName, this._firstName);
>
> If I just write a OLEDB function such as below, I always get 0. Even
> though
> the db has the newly added "person" and the autonumber is > 0.
>
> System.Data.OleDb.OleDbConnection con = new
> System.Data.OleDb.OleDbConnection(strConnection);
> int newID = 0;
> OleDbCommand idCMD = new OleDbCommand("SELECT @@IDENTITY", con);
> con.Open();
> newID = (int)idCMD.ExecuteScalar();
> con.Close();
>
>
> TiA
> Mike
Have you tried using the data adapters connection object rather than
creating a new one?
--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.
.
- Prev by Date: Re: how to copy selected rows in vb.net
- Next by Date: Re: VS.2005 c# Autonumber via Access with @@IDENTITY Failing
- Previous by thread: Re: how to copy selected rows in vb.net
- Next by thread: Re: VS.2005 c# Autonumber via Access with @@IDENTITY Failing
- Index(es):