Click here to Skip to main content
15,891,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to do a Insert into a existing SQLite table from C# code where one of the column name contains Hyphen.

I have the below code and getting the error saying 'SQL logic error or missing database
no such column: BLD'.

What I have tried:

sqLiteCommand.CommandText = @"INSERT INTO Status (Bit, PDI, 'PD-BLD') VALUES(@bit, @PDI, @PD-BLD)";

foreach (KeyValuePair<int, List<sts>> sts in statusDBFormat)
{
int bit = sts.Key;

sqLiteCommand.Parameters.Add(new SQLiteParameter("@Bit", bit));
foreach (Sts stsValue in sts.Value)
{

sqLiteCommand.Parameters.Add(new SQLiteParameter("@" + stsValue.tableName,
stsValue.value));

}
Posted
Updated 28-Mar-18 5:04am

1 solution

Try:
C#
sqLiteCommand.CommandText = @"INSERT INTO Status (Bit, PDI, [PD-BLD]) VALUES(@bit, @PDI, @PDBLD)";
 
Share this answer
 
v2
Comments
Member 13751531 28-Mar-18 11:42am    
Hi,I tried the changes you suggested, it works. Thanks a lot for your help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900