SqlConnection sqlConnection1 = new SqlConnection();
sqlConnection1.ConnectionString ="Server=(local);Database='"+ser+"';Integrated Security=no;UID='"+uid+"';Password='"+psw+"'";
sqlConnection1.Open();
SqlCommand sqlCommand = sqlConnection1.CreateCommand(); //调用SQL连接的方法CreateCommand来创建SQL命令;该命令将绑定SQL连接;
sqlCommand.CommandText = "insert into Necklist(MedicineName, Neckcounts, Reporter)values('" + Txt_medicinename.Text + "', '" + Txt_receivecounts.Text + "', '" + Txt_receivename.Text + "')"; //打开SQL连接;
sqlConnection1.Close();
本来就这样,要再往下执行一行才有值。