0

App works but UPDATE through WPF does not work

string sqlIns = "UPDATE Team_table SET result1 = '4:2' where name1=@Team1 and name2=@Team1";    
string Team1_string = Team1.Text;

// Team1, Team2, result1, result2 is the name of TextBox controls

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);

How to do it work?

3
  • 1
    Are you sure you don't a mistake between "@Team1" and "@Team2", "@result1". Your update command string contains one parameters : "@Team1". Check your code. Commented Nov 2, 2013 at 16:47
  • 1
    "Nice" names for variables, they driving me crazy. Especially, this one - TTKZS. Also, why don't use using for disposables? Commented Nov 2, 2013 at 16:48
  • No, there no mistake and ther is always hhconn. No ttkzs. )) This is from the past Commented Nov 3, 2013 at 7:35

2 Answers 2

3

Unless you are updating the rows when teams play themselves the error is from:

name1=@Team1 and name2=@Team1

I am fairly cofident you ment for that to be

name1=@Team1 and name2=@Team2
Sign up to request clarification or add additional context in comments.

5 Comments

I Agree With you. Great Point :)
:) Great I'm just waiting for the one who asked this Question.Okay let me do it.
But in SQL SERVER this works. For ex: UPDATE Team_table SET result1 = '6:2' where name1='Team1' and name2='Team2'
How to do it thhrough WPFTextbox via C#?
You made a typo, just fix it like I showed you, just replace name2=@Team1 with name2=@Team2 in the string sqlIns and it will work.
1

You are not setting connection string to SqlConnection Object properly

Replace this :

SqlConnection con = new SqlConnection(TTKZS);

with following :

 SqlConnection con = new SqlConnection(hhconn);

1 Comment

Yes, I see, i remade connection when post this message. Error is not from this. Sorry

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.