Jigar Desai

Jigar Desai

  • 552
  • 3.5k
  • 2m

Ideal way to retrive dataset.

Jul 12 2004 2:48 PM
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?

Brought to you by:

Answers (3)