Using sql 2005 and Vs2005 , snippet below.
Dim Conn As New SqlConnection(M y.Settings.Conn ectionString.To String)
Dim cmd As New SqlCommand
Dim MYPK as long
Conn.Open()
cmd.Connection = Conn
cmd.CommandText = "Insert Into Mytable (Field1,Field2)
Values('Value1' ,'Value2')"
"When executed, this inserts only one new row. How can I get the primary key
of that new record back into variable MYPK
Any help appreciated,
Bob
Dim Conn As New SqlConnection(M y.Settings.Conn ectionString.To String)
Dim cmd As New SqlCommand
Dim MYPK as long
Conn.Open()
cmd.Connection = Conn
cmd.CommandText = "Insert Into Mytable (Field1,Field2)
Values('Value1' ,'Value2')"
"When executed, this inserts only one new row. How can I get the primary key
of that new record back into variable MYPK
Any help appreciated,
Bob
Comment