Ruft eine gespeicherte Prozedur auf und gibt das Ergebnis in einem Dataset zurück.
/// <summary>
/// Get a DataSet from a stored procedure
/// </summary>
/// <param name="connectionString">the connectionstring</param>
/// <param name="storedProcedure">the name of the stored procedure</param>
/// <param name="tableName">the name of the DataTable in the Dataset</param>
/// <returns>the filled Dataset</returns>
private static DataSet GetDataSet(string connectionString, string storedProcedure, string tableName)
{
DataSet ds = new DataSet();
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand(storedProcedure, connection);
command.CommandType = CommandType.StoredProcedure;
SqlDataAdapter SdmDataAdapter = new SqlDataAdapter(command);
SdmDataAdapter.Fill(ds, tableName);
return ds;
}
Kommentare zum Snippet