1

I am using following code:

MySqlTransaction trnData = pconDB.BeginTransaction();
MySqlCommand cmdData = new MySqlCommand();

cmdData.Connection = pconDB;
cmdData.CommandTimeout = plngQueryTimeOut;
cmdData.CommandType = CommandType.Text;
cmdData.CommandText = "CALL spsOME( 4, 'DATA', 389552022,@intOutReturn);";
cmdData.Transaction = trnData;
plngRecordsCount = cmdData.ExecuteNonQuery();

Isn't CALL statement possible directly from .net library? The same query is working on workbench.

Phoenix
  • 1,045
  • 1
  • 14
  • 22
Sujit Rai
  • 445
  • 6
  • 10

1 Answers1

0

Change two lines to this:

   cmdData.CommandType = CommandType.StoredProcedure;
   cmdData.CommandText = "spsOME( 4, 'DATA', 389552022,@intOutReturn);";

You will also need to add a parameter to the Parameters collection of cmData for the @intOutReturn parameter. I won't give an example of this as the syntax varies with databases and I don't know what MySQL's looks like.

Also, this line:

cmdData.Transaction = trnData;

..is only necessary if you are doing other db operations which should be in the same transaction. If you're not, I'd leave that line out.

simon at rcl
  • 7,326
  • 1
  • 17
  • 24
  • I want to execute multiple CALL statements like this. `CALL spsOME( 4, 'DATA', 389552022,@intOutReturn); CALL spsOME( 4, 'DATA', 389552022,@intOutReturn);` Is it possible?? – Sujit Rai Jun 18 '14 at 10:18
  • Sure. But open another question for that, showing your code. – simon at rcl Jun 18 '14 at 10:43