The following example creates a
SQLiteCommand, then executes it by passing a string that is SQL SELECT statement, and a string to use to connect to the data source.
|
|---|
public void CreateSQLiteDataReader(string mySelectQuery,string sqLiteConnectionString)
{
SQLiteConnection sqLiteConnection = new SQLiteConnection(sqLiteConnectionString);
SQLiteCommand sqLiteCommand = new SQLiteCommand(mySelectQuery, sqLiteConnection);
sqLiteCommand.Connection.Open();
SQLiteDataReader sqLiteReader = sqLiteCommand.ExecuteReader();
try
{
while(sqLiteReader.Read())
{
Console.WriteLine(sqLiteReader.GetString(0));
}
}
finally
{
sqLiteReader.Close();
sqLiteConnection.Close();
}
} |
|
|---|
Public Sub CreateSQLiteDataReader(mySelectQuery As String, _
sqLiteConnectionString As String)
Dim sqLiteConnection As New SQLiteConnection(sqLiteConnectionString)
Dim sqLiteCommand As New SQLiteCommand(mySelectQuery, sqLiteConnection)
sqLiteCommand.Connection.Open()
Dim sqLiteReader As SQLiteDataReader = sqLiteCommand.ExecuteReader()
Try
While sqLiteReader.Read()
Console.WriteLine(sqLiteReader.GetString(0))
End While
Finally
sqLiteReader.Close()
sqLiteConnection.Close()
End Try
End Sub |