The following example creates a
UniCommand, then executes it by passing a string that is SQL SELECT statement, and a string to use to connect to the database.
public void CreateUniDataReader(string mySelectQuery,string myConnectionString)
{
UniConnection myConnection = new UniConnection(myConnectionString);
UniCommand myCommand = new UniCommand(mySelectQuery, myConnection);
myCommand.Connection.Open();
UniDataReader myReader = myCommand.ExecuteReader();
try
{
while(myReader.Read())
{
Console.WriteLine(myReader.GetString(0));
}
}
finally
{
myReader.Close();
myConnection.Close();
}
}
Public Sub CreateUniDataReader(mySelectQuery As String, _
myConnectionString As String)
Dim myConnection As New UniConnection(myConnectionString)
Dim myCommand As New UniCommand(mySelectQuery, myConnection)
myCommand.Connection.Open()
Dim myReader As UniDataReader = myCommand.ExecuteReader()
Try
While myReader.Read()
Console.WriteLine(myReader.GetString(0))
End While
Finally
myReader.Close()
myConnection.Close()
End Try
End Sub