Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

I try to find the ID of an inserted row.

this is my code:

 

                OleDbConnection Connection = new OleDbConnection();
               Connection = dbase(Connection);
               // Create an OleDb command,  
               OleDbCommand command = new OleDbCommand();
               command.Connection = Connection;
               command.CommandText = "insert into Bedrijven (Bedrijf,Contactpersoon,Adres,Postcode,Plaats,Tel,Mobiel,Fax,Email,Website,kvk,btw,debiteurnr,opmerkingen) values('" + Bedrijf + "','" + Contactpersoon + "','" + Adres + "','" + Postcode + "','" + Plaats + "','" + Tel + "','" + Mobiel + "','" + Fax + "','" + Email + "','" + Website + "','" + KVK + "','" + BTW + "','" + Debiteurnr + "','" + Opmerkingen + " ') ";                                
               command.ExecuteNonQuery();

 

Is it possible to get the ID of this row after the insert?

Posted

i use a .mdb file as database...

but there is no possibility to get it with command.id ore something?

 

Forum.. i know , how to change? :o

Posted

Sorry - just to elaborate on my previous post...

Dim sqlString As String = "select @@IDENTITY as MYID "
Dim localConn As New OleDbConnection(connString)
Dim localComm As New System.Data.OleDb.OleDbCommand(pSQL, localConn)
Dim myId As Int32 = DirectCast(localComm.ExecuteScalar(), Int32)

 

Paul.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...