[quote=引用 1 楼 findcaiyzh 的回复:] 试一试 strSQL = "INSERT INTO tablename (name) VALUES (@name);SELECT @@Identity" SQLCommand.CommandText = strSQL Id = SQLCommand.ExecuteScalar()
strSQL = "INSERT INTO tablename (name) VALUES (@name);SELECT @@Identity" SQLCommand.CommandText = strSQL Id = SQLCommand.ExecuteScalar()
试一试 strSQL = "INSERT INTO tablename (name) VALUES (@name);SELECT @@Identity" SQLCommand.CommandText = strSQL Id = SQLCommand.ExecuteScalar()
................. SqlCommand com = new SqlCommand(); com.CommandText = strCommand; int Id =(int)com.ExecuteScalar();
string strCommand=" insert infor values('"+TextBox2.Text+" ','"+TextBox3.Text+" ','"+TextBox4.Text+" ','"+TextBox5.Text+" ') ;SELECT @@Identity;"; SqlCommand.CommandText = strCommand; Integer Id = SqlCommand.ExecuteScalar(); 我这么写编译总出错。帮忙看看错在哪,谢咯!
[quote=引用 4 楼 u012366951 的回复:] string strCommand=" insert infor values('"+TextBox2.Text+" ','"+TextBox3.Text+" ','"+TextBox4.Text+" ','"+TextBox5.Text+" ') ;SELECT @@Identity;"; SqlCommand.CommandText = strCommand; Integer Id = SqlCommand.ExecuteScalar(); 我这么写编译总出错。帮忙看看错在哪,谢咯!
111,094
社区成员
642,554
社区内容
加载中
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧