C#操作SQLITE时SQL语句的一个坑

2020-08-19  本文已影响0人  Magna

报错语句:SqliteException: SQLite error no such column:

var mDbConnection = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;");
mDbConnection.Open();


const string sqlPart = @"REPLACE INTO watchList('cloumA', 'cloumB') VALUES ({0},{1})";
//此处需要强调的是,cloumA,cloumB必须有"'"存在,且valueA,valueB作为string插入时候,两端也必须有"'"即单引号

var sqlWords =  string.Format(sqlPart, valueA,valueB);
var command = new SQLiteCommand(sqlWords, mDbConnection);
command.ExecuteNonQuery();
Console.WriteLine("write success");
mDbConnection.Close();
上一篇下一篇

猜你喜欢

热点阅读