Hi I am using VB.Net 2002 with the Finisar.SQLite data provider to access the SQLite DBMS. I can access it no problem, insert, delete etc.. all fine. But what I am having trouble with is filling a dataset with the data within the table. I have attached the code I have created in the hope that someone can spot my mistake. I get the following error :- "Specified cast is not valid."
The following is part of a dbConnection.vb class :-
Dim dset As DataSet = New DataSet()
Public Function selectAll(ByVal strSQL As String)
sqlite_cmd.CommandText = (strSQL)
sqlite_datareader = sqlite_cmd.ExecuteReader()
Dim sqlite_dataAdapter As SQLiteDataAdapter = New SQLiteDataAdapter(strSQL, sqlite_conn)
sqlite_dataAdapter.Fill(dset) <<<<-------- Error highlights this line(Specified cast is not valid)
' The SQLiteDataReader allows us to run through the result lines:
While sqlite_datareader.Read()
dset = sqlite_datareader("text")
'MessageBox.Show(sqlite_datareader("text"))
End While
sqlite_datareader.Close()
Return dset
End Function
The following is from a button call to the selectAll function :-
Public Sub btnViewTable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnViewTable.Click
Dim dset As DataSet
dbConn.openExistingDatabse("Data Source=" & getDBName() & ";Version=3;New=False;Compress=True;")
dbConn.createSQLCommand()
tblName = (cmbInsertData.Text)
dbConn.selectAll("SELECT * FROM " & tblName)
DataGrid1.DataSource = dset.Tables(0).DefaultView
End Sub
|