- using (SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;
- Integrated Security=True;User Instance=True"))
- {
- conn.Open();
- using (SqlCommand comm = conn.CreateCommand())
- {
- comm.CommandText = "insert into t2(HAOMA,password) output inserted.password values ("+haoma+","+mima+")";
- // SqlDataReader reader= comm.ExecuteReader();
- comm.ExecuteScalar()//视频讲这句可以返回结果集第一行第一列 那为什么上面inserted.password 写的什么就返回什么 ???要是不写返回值为空!!
- Console.WriteLine("插值完毕");
复制代码 |