Ideal way to retrive dataset.
This is DataSet retriving code from IBUYSPY Events Module.
public DataSet GetEvents(int moduleId) {
// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
SqlDataAdapter myCommand = new SqlDataAdapter("GetEvents", myConnection);
// Mark the Command as a SPROC
myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
// Add Parameters to SPROC
SqlParameter parameterModuleId = new SqlParameter("@ModuleId", SqlDbType.Int, 4);
parameterModuleId.Value = moduleId;
myCommand.SelectCommand.Parameters.Add(parameterModuleId);
// Create and Fill the DataSet
DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet);
// Return the DataSet
return myDataSet;
}
My Question is
1) Is this ideal way to retrive data?
2) Will it return connection back to pool?


Giovanni Bejarasco34 reputationPosted Jul 16, 2004, 5:01 AM EDT
Jigar DesaiRank #780 · 2.9K reputationPosted Jul 19, 2004, 5:55 AM EDT
Giovanni Bejarasco34 reputationPosted Jul 23, 2004, 6:56 AM EDT