插入SQL语句后,返回刚插入记录的ID
执行完sql(insert)后 用@@identity 返回刚插入记录ID
1 string strSql = "INSERT INTO tablename ( number, vmoney, money) VALUES ('1', 1, 1);
select @@identity";
2 using (SqlDataObject sdo = new SqlDataObject())
3 {
4 object o = sdo.ExecuteScalar(strSql);
5 if (o != null)
6 lblID.Text = o.ToString();
7 }