c#调用sql时显示表名(use)的关键字附近有语法错误,求解
代码:privatevoidButton_Click(objectsender,RoutedEventArgse){SqlConnectionmysql=newSqlCo...
代码:
private void Button_Click(object sender, RoutedEventArgs e)
{
SqlConnection mysql = new SqlConnection("Data Source=PC-XUAN\\SQLEXPRESS;Integrated Security=True;Initial Catalog=SQLtest");
int i = 1;
string un = Text_username.Text, pwd = Text_password.Text;
SqlCommand Insert = new SqlCommand("INSERT INTO Use VALUES('"+i+"','"+un+"','"+pwd+"')",mysql);
try
{
mysql.Open();
Insert.ExecuteNonQuery();
mysql.Close();
}
catch(Exception ex)
{
Label_show.Content= ex;
}
} 展开
private void Button_Click(object sender, RoutedEventArgs e)
{
SqlConnection mysql = new SqlConnection("Data Source=PC-XUAN\\SQLEXPRESS;Integrated Security=True;Initial Catalog=SQLtest");
int i = 1;
string un = Text_username.Text, pwd = Text_password.Text;
SqlCommand Insert = new SqlCommand("INSERT INTO Use VALUES('"+i+"','"+un+"','"+pwd+"')",mysql);
try
{
mysql.Open();
Insert.ExecuteNonQuery();
mysql.Close();
}
catch(Exception ex)
{
Label_show.Content= ex;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询