string strSql = "insert into table(a,b,c) values('1','2','3') SELECT SCOPE_IDENTITY();"
查询:
//存入数据库
public static int operateSqlServerDbAndReturnPrimaryKey(string strSql)
{
//update,insert,delete
SqlConnection conn = DB.getConnection();
SqlCommand sqlcmd = new SqlCommand(strSql, conn);
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
int rtn = Convert.ToInt32(sqlcmd.ExecuteScalar());
conn.Close();
sqlcmd.Dispose();
return rtn;
}