2

i have a problem where i can't apparently find a solution even after hours of debugging.

I have a simple SQL command where i want to update a row with some value(the value is a text of about ~5mb), after executing the SQL Command, the 'ExecuteNonQuery()' on the C# code side, returns '1' and no exception but the changes are sometime reflected in the Database row and sometime not.

I tried debugging to see if the values that will replace the old one are correct and they are. I am using MySQL 5.5.11.

  • Could it be a MySQL setting or something?

Losing my mind on this problem, if you have any idea it would be greatly appreciated.

EDIT, include code:

The code is as simple as this:

cmd.CommandText = "UPDATE user SET data = @data WHERE id = @id";

then i add params to the DBCommand object for the SQL Query. The 'data' is about ~5mb big.

this command always returns '1' even if the changes are not reflected in the database(sometime it works, sometime it doesnt):

cmd.ExecuteNonQuery();

Thanks in advance!

3
  • 2
    Post some code, so we can: 1) see exactly what you are doing, and how you are doing it, and 2) so we could perhaps reproduce the same issue. Commented Jun 10, 2012 at 18:32
  • 1
    I had a similar problem and I've removed the column and recreated it. Don't askme why, but it worked. The MySql drivers have a few problems with MS products. Commented Jun 10, 2012 at 18:34
  • Have you tried to update the row with a shorter text? Commented Jun 10, 2012 at 18:36

3 Answers 3

1

I don't know if the mysql provider uses autocommit? If not then you have to call commit on the Transaction object you can get with BeginTransaction on the connection object.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the reply, i dont know but i am not using transaction object, so i don't know why sometime it works and sometime not?
0

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx

The Microsoft .NET Framework Data Provider for SQL Server does not support the question mark (?) placeholder for passing parameters to a SQL Statement or a stored procedure called by a command of CommandType.Text. In this case, named parameters must be used.

For example:

SELECT * FROM Customers WHERE CustomerID = @CustomerID 

Edit: Just noticed this was MySQL, and while i can't find anything simliar about it quickly, i would suggest you use named parameters anyways

1 Comment

Thanks for the reply, but i wrote the code example from the top of my head, actually the code use @param, i'll edit my OP.
0

I had this problem and it was related to autocommit.

Problem: earlier in the app lifespan autocommit was set to 0 by another process in the app, and failed. The connection with autocommit turned off is then reused by the connection pool.

That will lead to this type of error at unpredictable times.

1 Comment

note that it will happen even if not using transactions. The connection has been set so nothing is committed without a COMMIT.

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.