Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to Create a table and name it after a record stored in a class

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();

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading