Remarque
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de vous connecter ou de modifier des répertoires.
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de modifier des répertoires.
L’objet SqlDataRecord représente une seule ligne de données, ainsi que ses métadonnées associées.
Les procédures stockées gérées peuvent envoyer aux jeux de résultats clients qui ne proviennent pas d’un SqlDataReader. La classe SqlDataRecord, ainsi que les méthodes SendResultsStart, SendResultsRowet SendResultsEnd de l’objet SqlPipe, permet aux procédures stockées d’envoyer des jeux de résultats personnalisés au client.
Pour plus d’informations, consultez la documentation de référence sur la Microsoft.SqlServer.Server.SqlDataRecord classe dans la documentation du Kit de développement logiciel (SDK) .NET Framework.
Exemple :
L'exemple suivant crée un nouvel enregistrement d'employé et le retourne à l'appelant.
C#
[Microsoft.SqlServer.Server.SqlProcedure]
public static void CreateNewRecordProc()
{
// Variables.
SqlDataRecord record;
// Create a new record with the column metadata. The constructor
// is able to accept a variable number of parameters.
record = new SqlDataRecord(new SqlMetaData("EmployeeID", SqlDbType.Int),
new SqlMetaData("Surname", SqlDbType.NVarChar, 20),
new SqlMetaData("GivenName", SqlDbType.NVarChar, 20),
new SqlMetaData("StartDate", SqlDbType.DateTime) );
// Set the record fields.
record.SetInt32(0, 0042);
record.SetString(1, "Funk");
record.SetString(2, "Don");
record.SetDateTime(3, new DateTime(2005, 7, 17));
// Send the record to the calling program.
SqlContext.Pipe.Send(record);
}
Visual Basic
<Microsoft.SqlServer.Server.SqlProcedure()> _
Public Shared Sub CreateNewRecordVBProc ()
' Variables.
Dim record As SqlDataRecord
' Create a new record with the column metadata. The constructor is
' able to accept a variable number of parameters
record = New SqlDataRecord(New SqlMetaData("EmployeeID", SqlDbType.Int), _
New SqlMetaData("Surname", SqlDbType.NVarChar, 20), _
New SqlMetaData("GivenName", SqlDbType.NVarChar, 20), _
New SqlMetaData("StartDate", SqlDbType.DateTime))
' Set the record fields.
record.SetInt32(0, 42)
record.SetString(1, "Funk")
record.SetString(2, "Don")
record.SetDateTime(3, New DateTime(2005, 7, 17))
' Send the record to the calling program.
SqlContext.Pipe.Send(record)
End Sub