0

应用程序工作,但通过 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);

如何做到这一点?

4

2 回答 2

3

除非您在团队自己比赛时更新行,否则错误来自:

name1=@Team1 and name2=@Team1

我相当有信心你会这样做

name1=@Team1 and name2=@Team2
于 2013-11-02T16:53:11.123 回答
1

您没有正确地将连接字符串设置为 SqlConnection 对象

替换这个:

SqlConnection con = new SqlConnection(TTKZS);

有以下内容:

 SqlConnection con = new SqlConnection(hhconn);
于 2013-11-02T16:43:16.580 回答