I'm trying to create a table that will use the name of an ID code stored in a class(Named UserInfo in the code). I've also tried storing the data as a string variable, but I keep getting : 'SQL logic error near "83883": syntax error. My Code:
sqlite_conn.Open();
sqlite_conn = new SQLiteConnection("Data Source=RetailSystem.db; Version = 3; New = True; Compress = True;");
string MakeBsketTable = "CREATE TABLE IF NOT EXISTS " UserInfo.CustomerID " (BasketItemName VARCHAR(40), IndividualItemQuantity INT, IndividualItemPrice INT, TotalItemQuantity INT, TotalItemCost INT, GrossCost INT)";
sqlite_cmd = sqlite_conn.CreateCommand();
sqlite_cmd.CommandText = MakeBsketTable;
sqlite_cmd.ExecuteNonQuery();
CodePudding user response:
There's no need to create a table with an Id as the name, since it's a table you can have multiple records in it. You can add the Id primary key field on the table which will be neater
CodePudding user response:
For starters, I don't see the logic in creating a table named as an ID. It is much easier to create several tables with a relationship between them. Read about database normalization.
Secondly, any query in SQL must end with symbol ";".