应用可行,但通过WPF更新无效
string sqlIns = "UPDATE Team_table SET result1 = '4:2' where name1=@Team1 and name2=@Team1";
string Team1_string = Team1.Text;
// Team1,Team2,result1,result2是TextBox控件的名称
cmdIns.Parameters.AddWithValue("@Team1", Team1_string);
string Team2_string = Team2.Text;
cmdIns.Parameters.AddWithValue("@Team2", Team2_string);
string result1_string = Result1.Text;
cmdIns.Parameters.AddWithValue("@result1", result1_string);
如何运作?
答案 0 :(得分:3)
除非您在团队自己玩游戏时更新行,否则错误来自:
name1=@Team1 and name2=@Team1
我非常赞同你的意思
name1=@Team1 and name2=@Team2
答案 1 :(得分:1)
您没有正确设置连接字符串到SqlConnection对象
替换为:
SqlConnection con = new SqlConnection(TTKZS);
以下内容:
SqlConnection con = new SqlConnection(hhconn);