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();
}
}
建议检查下数据库 你这个角色应该有点东西 换一个试试
还有你这个button能不能好好起名
"Server=192.168.0.4;UID=sa;PWD=JStjsy123;DataBase=ufdata_008_2013";
检查下你的服务器地址(以及网络是否能联通)、用户名、密码,是否允许防火墙、tcpip协议,以及远程访问