private void button6_Click(object sender, EventArgs e)
{
SqlConnection cnn = new SqlConnection();
cnn.ConnectionString = "Server=192.168.0.4;UID=sa;PWD=JStjsy123;DataBase=ufdata_008_2013";
try
{
cnn.Open();
string Sqlstr = @"update temp set temp = 212 where temp = 22";
SqlCommand myCommand = new SqlCommand(Sqlstr);
myCommand.Connection = cnn;
int i = Convert.ToInt32(myCommand.ExecuteNonQuery());
MessageBox.Show("连接成功消息", "消息标题");
}
catch
{
MessageBox.Show("连接失败消息", "消息标题");
}
finally
{
cnn.Close();
}
}
c# update 数据库始终报连接失败,请指点
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-