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 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]