• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

SQLite "No such column" When there clearly is... [VB.net]

Ben711Gaming

New Coder
I am new to SQLite and am trying to make a program that creates a database (if it doesn't already exist) then allow the user to input data. When I go to press 'input data' it gives the error "Microsoft.Data.Sqlite.SqliteException: 'SQLite Error 1: 'no such column: CustomerID'.'".
I can use DB Browser for SQLite and see that there is a CustomerID column made by the code. I just don't know why it is not recognised.

SQL Statement:
Dim CMD As String =
                "INSERT INTO Record (CustomerID, FirstName, LastName, RoomNumber, StayLength, Phone, Postcode)
                 VALUES (CustomerID, FName, LName, RoomNum, StayLength, PhoneNumber, Postcode)"
            Dim SQLCmd As New SqliteCommand(CMD, Connection)
            Connection.Open()
            SQLCmd.ExecuteNonQuery()
            Connection.Close()
            MsgBox("Data Inserted")


Table creation:
If FileExists = False Then
            Dim SQLCommand As String =
                "CREATE TABLE Record (CustomerID TEXT,
                                      FirstName TEXT,
                                      LastName TEXT,
                                      RoomNumber TEXT,
                                      StayLength TEXT,
                                      Phone TEXT,
                                      Postcode TEXT)"
            Dim cmd As New SqliteCommand(SQLCommand, Connection)
            Connection.Open()
            cmd.ExecuteNonQuery()
            Connection.Close()
            MsgBox("Database 'Record.db' created!")
        End If
 

simong1993

Active Coder
Staff Team
Guardian
I've never used SQLite but this seems very similar to SQL and i have used that a lot. Just a few things to check. Make sure in your database that your table has a Capital R as some versions will automatically turn a caps into a lower case.

Check your table structure and make sure your SQL query has not added a extra space at the end.
 

Top