sql >> Database teknologi >  >> RDS >> Sqlserver

Hent data fra lagret procedure, som har flere resultatsæt

String myConnString  = "User ID="username";password="password";Initial Catalog=pubs;Data Source=Server";
SqlConnection myConnection = new SqlConnection(myConnString);
SqlCommand myCommand = new SqlCommand();
SqlDataReader myReader ;

myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Connection = myConnection;
myCommand.CommandText = "MyProc";

try
{
    myConnection.Open();
    myReader = myCommand.ExecuteReader();

    while (myReader.Read())
    {
        //Write logic to process data for the first result.   
        }

    myReader.NextResult();
    while (myReader.Read())
    {
        //Write logic to process data for the second result.
    }
}


  1. Konfigurer opstartsmiljø i SQL Server Management Studio (SSMS) - SQL Server / TSQL vejledning del 7

  2. dødvande i Oracle

  3. Brug af Salesforce SOQL fra Linux

  4. Brug for en datetime-kolonne i SQL Server, der automatisk opdateres, når posten ændres