GetValues Method (PgSqlDataReader)
Gets all column values for the current row.
|
|---|
'Declaration
Public Overrides Function GetValues( _
ByVal () As Object _
) As Integer |
Parameters
- values
- An array of System.Object into which to copy the attribute column values.
Return Value
The number of instances of
System.Object in the array.
The example shows how to retrieve several fields at once. Note that only the first three fields are retrieved, though there may be more in the table.
|
|---|
public void GetObjects(PgSqlConnection pgSqlConnection)
{
PgSqlCommand cmd = new PgSqlCommand("SELECT * FROM Test.Emp");
cmd.Connection = pgSqlConnection;
pgSqlConnection.Open();
try
{
PgSqlDataReader reader = cmd.ExecuteReader();
reader.Read();
object[] objs = new object[3];
int quant = reader.GetValues(objs);
for (int i=0;i < quant;i++)
{
Console.WriteLine(objs[i]);
}
reader.Close();
}
finally
{
pgSqlConnection.Close();
}
} |
|
|---|
Public Sub GetObjects(ByVal pgSqlConnection As PgSqlConnection)
Dim cmd As PgSqlCommand = New PgSqlCommand("SELECT * FROM Test.Dept")
cmd.Connection = pgSqlConnection
pgSqlConnection.Open()
Try
Dim reader As PgSqlDataReader = cmd.ExecuteReader()
reader.Read()
Dim objs(3) As Object
Dim quant As Integer = reader.GetValues(objs)
Dim i As Integer
For i = 0 To quant - 1
Console.WriteLine(objs(i))
Next i
reader.Close()
Finally
pgSqlConnection.Close()
End Try
End Sub |