Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

Stored procedure paramter passing (1 reply)

$
0
0
I have been readind both MSDN and the Connector's docs and the only examples I find are using cmd.Parameters.AddWithValue.

What I really need to do, though, is setting the UpdateCommand of an DataAdapter to be the the stored procedure.

What I am doing (in C#) is the following (split is a custom object that has a DataAdapter member exposed via the DataAdapter property).

-------------
var updateCmd = new MySqlCommand("updateBrokerSymbols");
var param = new MySqlParameter("@ghrSym", MySqlDbType.VarChar, 9, "ghr_symbol");
param.Direction = ParameterDirection.Input;
updateCmd.Parameters.Add( param.Clone() );

param = new MySqlParameter("@broker", MySqlDbType.VarChar, 10, "broker");
param.Direction = ParameterDirection.Input;
updateCmd.Parameters.Add( param.Clone() );

param = new MySqlParameter("@brokerSym", MySqlDbType.VarChar, 9, "broker_symbol");
param.Direction = ParameterDirection.Input;
updateCmd.Parameters.Add( param.Clone() );

split.DataAdapter.UpdateCommand = updateCmd.Clone();
-------------

When I modify the data in the DataGridView and then launch the update, tgough, I get the following Exception:
"Incorrect number of arguments for PROCEDURE ghr.updateBrokerSymbols; expected 3, got 0"

Any ideas? Help would be greatly appreciated.

Viewing all articles
Browse latest Browse all 1451

Trending Articles