Unable to MySqlCommand.ExecuteNonQuery()
Posted by: Bernardo Balvanera
Date: February 02, 2007 04:25PM

Hi to all.

I'm not sure if I'm doing something wrong.
I have a very simple rutine to execute a storeprocedure. The sproc does not accept parameters. This is my code:

MySqlConnection cn = new MySqlConnection(AvalidConnectionStringGoesHere);
MySqlCommand cmd = new MySqlCommand("MySproc", cn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;

cn.Open();
int result = cmd.ExecuteNonQuery();
cn.Close();
cmd.Dispose();

Every time a execute the above code, I get a SqlNullValueException. I was able to track down the cause of the problem and it seems that the MySqlCommand is calling ExecuteReader internaly before calling ExecuteNonQuery. Is trying to execute the following statement: SHOW CREATE PROCEDURE myschema.mysproc;

The problem is that this statement returns 3 columns, but when the executeReader is called, the 3th column comes back as empty, so when trying to read this field it raises a SqlNullValueException from within the reader. So the ExecuteNonQuery never executes.

I don't know if anyone can help me with this issue.

Thx
Bernardo



Edited 1 time(s). Last edit at 02/02/2007 04:25PM by Bernardo Balvanera.

Options: ReplyQuote


Subject
Written By
Posted
Unable to MySqlCommand.ExecuteNonQuery()
February 02, 2007 04:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.