为什么添加不了数据呢
我通过一个添加按钮向数据库中添加数据,不报错,但是数据库中没有数据,是怎么回事啊我的代码如下:
private void btnadd_Click(object sender, System.EventArgs e)
{ SqlConnection sqlcon = new SqlConnection("server=.;database=peisong; uid=sa;pwd=;");//创建SqlConnection对象
sqlcon.Open();
SqlCommand cmd = new SqlCommand();
into user values (@username,@storename,@post,@powerid,@dlname,@pwd,"
+"@sex,@birthday,@cardid,@ustelephone,@usaddress)";
cmd.Parameters.Add("@username",username.Text.ToString());
cmd.Parameters.Add("@storename",this.store.SelectedItem.Value);
cmd.Parameters.Add("@post",this.post.SelectedItem.Value);
cmd.Parameters.Add("@powerid",this.power.SelectedItem.Value);
cmd.Parameters.Add("@dlname",dlname.Text.ToString());
cmd.Parameters.Add("@pwd",pwd.Text.ToString());
cmd.Parameters.Add("@sex",this.sex.SelectedItem.Value);
cmd.Parameters.Add("@birthday",DateTime.Now);
cmd.Parameters.Add("@cardid",cardid.Text.ToString());
cmd.Parameters.Add("@ustelephone",tel.Text.ToString());
cmd.Parameters.Add("@usaddress",address.Text.ToString());
cmd.Connection=sqlcon;
cmd.ExecuteNonQuery();
sqlcon.Close();