Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi m using this subroutine to save a datatable but i always get a SQL syntax error
VB
Public Sub SaveDt(ByRef dt As DataTable, ByVal DatabaseFile As String)
        

            If My.Computer.FileSystem.FileExists(DatabaseFile) Then       
            My.Computer.FileSystem.DeleteFile(DatabaseFile)
            End If

            SQLiteConnection.CreateFile(DatabaseFile)

        Try
            dbLiteConn = New SQLiteConnection(setConn_Lite(DatabaseFile))

            dbLiteComd = dbLiteConn.CreateCommand()
            dbLiteComd.CommandText = String.Format("SELECT * FROM {0}", dt.TableName)

            dbLiteAdapt = New SQLiteDataAdapter(dbLiteComd)
            Dim dbLitebuilder As New SQLiteCommandBuilder(dbLiteAdapt)

            dbLiteAdapt.Update(dt)

            dbLiteConn.Close()

        Catch Ex As Exception
            MessageBox.Show(Ex.Message)
        End Try

    End Sub
Posted
Updated 7-Jun-15 11:43am
v3
Comments
Richard MacCutchan 8-Jun-15 3:50am    
You are trying to read records from a database that has not been created. You should be creating the tables and filling them with records from the datatable.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900