c#怎么返回所有插入数据库的数据
1个回答
2017-09-25
展开全部
c#怎么返回所有插入数据库的数据
string str = "Data Source=.;Initial Catalog=data;Integrated Security=True";
SqlConnection conn = new SqlConnection(str);
string sql = "insert into person (Age,Name) output inserted.Id values(20,'name');select @@identity";
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
int i=(int)cmd.ExecuteScalar();
conn.close();
MessageBox.Show(i.ToString());
string str = "Data Source=.;Initial Catalog=data;Integrated Security=True";
SqlConnection conn = new SqlConnection(str);
string sql = "insert into person (Age,Name) output inserted.Id values(20,'name');select @@identity";
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
int i=(int)cmd.ExecuteScalar();
conn.close();
MessageBox.Show(i.ToString());
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询