I am trying to fill a dataset with the result of a stored procedure using MySql and Mono.
The stored procedure takes in some values, creates a new row in a table and then selects some rows.
When I try this I get back an empty dataset and my database does not have any new records. I have checked the basics:
- The Database is running and I can connect.
- The stored procedure name and parameter names are correct.
- The parameter types are correct.
- The stored procedure works correctly from an sql command line.
If I don't use a stored procedure and set the command.commandtext to some sql it returns a dataset with data.
Here is a code snippet that showing what I am trying to do.
ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings [this.provider];
DbProviderFactory factory = DbProviderFactories.GetFactory (connectionStringSettings.ProviderName);
using(DbConnection connection = factory.CreateConnection())
{
connection.ConnectionString = connectionStringSettings.ConnectionString;
connection.Open();
using(DbCommand command = connection.CreateCommand()) {
command.CommandText = "createUser";
command.CommandType = CommandType.StoredProcedure;
dbParameter dbParameter = factory.CreateParameter();
dbParameter.ParameterName = "@name";
dbParameter.Value = "Fred.Smith";
command.Parameters.Add(dbParameter);
DataSet dataset = new DataSet();
DbDataAdapter adaptor = factory.CreateDataAdapter();
adaptor.SelectCommand = command;
adaptor.Fill(dataset);
//This is all ways empty
return dataset;
}
}