为什么我用c#语言写的语句改变不了sql数据库中的数据(在数据库中添加不了记录)
using(SqlConnectionconn=newSqlConnection(connectionString)){//stringsql1="insertintoU...
using (SqlConnection conn = new SqlConnection(connectionString))
{
//string sql1 = "insert into Usertable(Username,name,Upassword,Umoney) values(@Username,@name,@Upassword,@Umoney)";
conn.Open();
try
{
SqlCommand cmd = new SqlCommand("insert into Usertable(Username,name,Upassword,Umoney) values('11','11','11',12)", conn);
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("添加成功");
}
catch (Exception err)
{
MessageBox.Show(err.Message);
} 展开
{
//string sql1 = "insert into Usertable(Username,name,Upassword,Umoney) values(@Username,@name,@Upassword,@Umoney)";
conn.Open();
try
{
SqlCommand cmd = new SqlCommand("insert into Usertable(Username,name,Upassword,Umoney) values('11','11','11',12)", conn);
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("添加成功");
}
catch (Exception err)
{
MessageBox.Show(err.Message);
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询