F
fniles
I am using VB.NET 2005 and Access database.
In the database I have table (myTbl) with a column called ID as a primary
key, and it is a counter field.
When I insert into myTbl, how can I get the value of ID ?
Private m_cmd As OleDb.OleDbCommand
m_cmd = New OleDb.OleDbCommand
sSQL = "insert into myTbl (col1,col2) VALUES (?,?)"
m_cmd.Parameters.Add("@col1", OleDb.OleDbType.VarChar, 50, "col1")
m_cmd.Parameters.Add("@col2", OleDb.OleDbType.VarChar, 50, "col2")
m_cmd.Parameters("@col1").Value = sParameterValue1
m_cmd.Parameters("@col2").Value = sParameterValue2
With m_cmd
.Connection = adoConOLE
.CommandText = sSQL
End With
m_cmd.ExecuteNonQuery()
How can I get the value of the column ID ?
m_cmd.Parameters.Add("@ID" & sParameterName, OleDb.OleDbType.BigInt, 4,
"ID").Direction = ParameterDirection.Output '--> Can I do this, and if I
can, is the following sql statement correct ?
insert into myTbl (col1,col2) VALUES (?,?)
Thank you.
In the database I have table (myTbl) with a column called ID as a primary
key, and it is a counter field.
When I insert into myTbl, how can I get the value of ID ?
Private m_cmd As OleDb.OleDbCommand
m_cmd = New OleDb.OleDbCommand
sSQL = "insert into myTbl (col1,col2) VALUES (?,?)"
m_cmd.Parameters.Add("@col1", OleDb.OleDbType.VarChar, 50, "col1")
m_cmd.Parameters.Add("@col2", OleDb.OleDbType.VarChar, 50, "col2")
m_cmd.Parameters("@col1").Value = sParameterValue1
m_cmd.Parameters("@col2").Value = sParameterValue2
With m_cmd
.Connection = adoConOLE
.CommandText = sSQL
End With
m_cmd.ExecuteNonQuery()
How can I get the value of the column ID ?
m_cmd.Parameters.Add("@ID" & sParameterName, OleDb.OleDbType.BigInt, 4,
"ID").Direction = ParameterDirection.Output '--> Can I do this, and if I
can, is the following sql statement correct ?
insert into myTbl (col1,col2) VALUES (?,?)
Thank you.