G
Guest
Hi;
When I do an insert, how do I get the primary key:
Note: I am doing this with a DbCommand and doing an insert using
ExecuteNonQuery. In other words, no DataTable, no DataAdapter, just basic
direct access.
Please answer for all supported databases. I figure this includes Sql
Server, Oracle (OracleClient), ODBC (OdbcClient), OleDb (OleDbClient),
SqlServerExpress if different from SqlServer, and Jet/Access. (info for
non-supported databases would be welcome too.)
I have looked everywhere - msdn, google, etc but all the samples assume a
DataTable and a named column to return the result in. Or they have a select
in a GridView or other control and again a named param that gets put in the
object representing the row. (I am open to the DataTable approach if it means
a common select statement but from what I can tell, even with a DataTable,
the selects are still database dependent.)
When I do an insert, how do I get the primary key:
Note: I am doing this with a DbCommand and doing an insert using
ExecuteNonQuery. In other words, no DataTable, no DataAdapter, just basic
direct access.
Please answer for all supported databases. I figure this includes Sql
Server, Oracle (OracleClient), ODBC (OdbcClient), OleDb (OleDbClient),
SqlServerExpress if different from SqlServer, and Jet/Access. (info for
non-supported databases would be welcome too.)
I have looked everywhere - msdn, google, etc but all the samples assume a
DataTable and a named column to return the result in. Or they have a select
in a GridView or other control and again a named param that gets put in the
object representing the row. (I am open to the DataTable approach if it means
a common select statement but from what I can tell, even with a DataTable,
the selects are still database dependent.)