Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All, I have an unusual problem. My code worked fine for months and now all of a sudden it gives me an error and I did not change a thing in this area. The code swaps two column values when a user presses a button. This is simple right? well it does not work anymore. I don't know what went wrong. I thought it might be that I updated my MySQL database, but when I try to use the syntax in MySQL itself, it is working. So the problem is with my code..

This is my code:

C#
public void UpdatePayment(int paymentId)
        {
            using (MySqlConnection Conn = new MySqlConnection(Connect.sConnStr))
            {
                Conn.Open();
                string sSql = "UPDATE payments SET amount=(@temp:=amount), amount = owes, owes = @temp WHERE payment_id = " + paymentId + ";";
                int iReturn = Biogym.Service.Classes.Connect.getDataCommand(sSql, Conn).ExecuteNonQuery();
                Conn.Close();
                Conn.Dispose();
            }
        }


What is wrong?? It suddenly says "Parameter @temp is not defined", but I mean how can it work for months and suddenly stop??
Posted
Comments
dan!sh 5-Mar-14 13:20pm    
[joke]Find your team mate and beat him.[/joke]

Sorry, I am not much into MySql so cannot really help here.
Sergey Alexandrovich Kryukov 5-Mar-14 13:26pm    
Worked for month? suddenly? do you mean that you did not change any code?
—SA
Christopher Smit 5-Mar-14 13:29pm    
Exactly... This is very strange to me.. Everything worked fine, then I updated my MySQL on my computer, but I'm sure it still worked after that, tonight when I tried to debug again and check if I could find any errors, this suddenly started to happen. I mean it's not possible? If no code was changed, how can it just stop??
Christopher Smit 5-Mar-14 13:38pm    
I think I figured it out. It might have something to do with the update of MySQL... I notice that I do not get the error when I swap column values where both columns have values higher than 0. If one column has a value of 0 then I get the error. I never got it before, but I do now so I will have to try and change the code so that it swaps the values differently in case a 0 is found. :)
Sergey Alexandrovich Kryukov 5-Mar-14 14:07pm    
Well, by the method of excluding the factors... it could be the only reason...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900