Feedback

C# - Dataset mit Stored Procedure füllen

Veröffentlicht von am 6/12/2007
(0 Bewertungen)
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;
}
Abgelegt unter Stored Procedure, DataSet.

Kommentare zum Snippet

 

Logge dich ein, um hier zu kommentieren!