Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • 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.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • 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.

[CODE title="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")[/CODE]


[CODE title="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[/CODE]
 
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.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom