data adapter fill() fails on stored procedure however execute reader works.
Posted by: Megan Woods
Date: November 24, 2006 08:13PM

Hi,

Using the following code when I attempt to fill the data adapter the system throws an exception with the message 'connection unexpectidly terminated'.

However when I use the exact same command but I use the ExecuteReader method it returns somthing and does not throw an exception of any type and finishes properly. (See commented out bits)

I come from a java on unix background and this is my first real round of C# in anger so if anyone has any suggestions I would appreciate your feedback.

Cheers Megan



searchCommand.CommandText = "SearchEmployee";
searchCommand.Connection.Open();
employeeDataAdapter.SelectCommand = searchCommand;
searchCommand.CommandType = CommandType.StoredProcedure;
searchCommand.Parameters.Add("?querystr", MySqlDbType.VarChar).Value="1";
searchCommand.Parameters[0].Direction = ParameterDirection.Input;
searchCommand.Parameters.Add("?orderby", MySqlDbType.VarChar, 20).Value = "emp_id";
searchCommand.Parameters[1].Direction = ParameterDirection.Input;
searchCommand.Parameters.Add("?direction", MySqlDbType.VarChar, 5).Value = "asc";
searchCommand.Parameters[2].Direction = ParameterDirection.Input;
searchCommand.Parameters.Add("?offst", MySqlDbType.Int16).Value = 0;
searchCommand.Parameters[3].Direction = ParameterDirection.Input;
searchCommand.Parameters.Add("?rowcount", MySqlDbType.Int16).Value = 1000;
searchCommand.Parameters[4].Direction = ParameterDirection.Input;


searchCommand.Prepare();

//MySqlDataReader reader = searchCommand.ExecuteReader();
//MessageBox.Show("Reader: "+reader.FieldCount);
//reader.Close();
//searchCommand.Dispose();
//DataBase.CloseConnection();


employeeDataAdapter.Fill(employeeDataTable);

Options: ReplyQuote


Subject
Written By
Posted
data adapter fill() fails on stored procedure however execute reader works.
November 24, 2006 08:13PM


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.