执行完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 }
其中SqlDataObject是自己写的执行SQL的类。


















浙公网安备 33010602011771号