执行 C# SQL 数据插入时出现语法错误

发布于 2025-01-10 22:30:20 字数 10206 浏览 0 评论 0原文

string query = $"insert into MessageData values(NULL,'{rehberIsmi}','{jsonData}','{DateTime.Now}')";

using (SQLiteConnection conn = new SQLiteConnection(DatabaseInformation.ConnectionString))
{
    try
    {
        conn.Open();

        SQLiteCommand com = new SQLiteCommand(query, conn);
        com.ExecuteNonQuery();

        conn.Close();
    }
    catch (Exception ex)
    {
       MessageBox.Show("Bir hata meydana geldi : " + ex.Message, "Hata", 
       MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}

我正在使用上面的代码将数据输入到 SQLite 数据库中,但是在获取一些字符串值时,我收到此错误:

'“da”附近的 SQL 逻辑错误:语法错误'

原因是什么?

Wrong json value : "[
{"avatar":"","position":"right","time":"2021.02.12 12:43:54","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"+905416379800","msg":"Merhabalar Sizlere nasıl yardımcı olabilirim."},
{"avatar":"","position":"left","time":"2021.02.12 12:43:55","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Merhaba"},{"avatar":"","position":"left","time":"2021.02.12 12:44:03","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Senet ile satışınız varmı"},{"avatar":"","position":"left","time":"2021.02.12 12:44:16","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Kanunu mati 125 için"},{"avatar":"","position":"left","time":"2021.02.12 12:44:20","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Bilgi almak istiyorum"},{"avatar":"","position":"left","time":"2021.02.12 12:44:29","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"10 bin peşin versek diğerini"},{"avatar":"","position":"left","time":"2021.02.12 12:44:37","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"12 aya bölsek nasıl olur"},{"avatar":"","position":"right","time":"2021.02.12 13:39:26","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"+905416379800","msg":"https://www.ekuralkan.com/mati-42313 peşin fiyatı 22.353 TL dir. Tüm modellerimizi minimum %25 peşinat ile 36 aya varan taksitler ile alabilirsiniz. https://www.ekuralkan.com/senetli-satis-basvuru\nhttps://blog.ekuralkan.com/\nhttps://www.youtube.com/channel/UCKRIe5B_60bNIR6uSkhxR1g"},{"avatar":"","position":"right","time":"2021.02.12 13:39:36","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"+905416379800","msg":"Sitemiz de vade oranlarını inceleyebilirsiniz"},{"avatar":"","position":"left","time":"2021.12.12 23:52:20","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Bağlantı:\nhttps://www.instagram.com/p/CXTcf_-jRQM/\n\nBunu Instagram'da gördüm..."},{"avatar":"","position":"right","time":"2021.12.12 23:52:20","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Mesajınız için teşekkür ederiz. Mesai saatlerimiz hafta içi 07:00 & 17:00’dir. Mesai saatleri içinde en kısa sürede size cevap vereceğiz."},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"https://www.ekuralkan.com/mati-42313 peşin fiyatı 22.353 TL dir. Tüm modellerimizi minimum %25 peşinat ile 36 aya varan taksitler ile alabilirsiniz. https://www.ekuralkan.com/senetli-satis-basvuru\nhttps://blog.ekuralkan.com/\nhttps://www.youtube.com/channel/UCKRIe5B_60bNIR6uSkhxR1g"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Kolay gelsin"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Senentle satış varmı ?"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Findeks üyeliğiniz varsa senetli alım başvurunuzu yapabiliriz"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Nasıl oluyor o"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"kredi notudur"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"internetten kendiniz üye olmanız gerekiyor"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Onu biliyorum"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Findex üyeliğimiz var zaten de"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Başvuruyu nasıl yapıyoruz"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"37.65 KB","mediaName":"attachment_743","mediaTime":"0\"","localPath":"media\\attachment_743","thumbPath":"media\\attachment_743","delete":"false","type":"photo","identifier":"","msg":"IMG-20211213-WA0001.jpg"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"başvurunuzu buradan yapabiliriz siteden kendiniz de yapabilirsiniz"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Link alabilirmiyim"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Bi türlü bulamadım"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"https://isube.findeks.com/ers/uyelik/bireyselUyelik.xhtml"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Üyeliğim var zaten"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"https://www.ekuralkan.com/senetli-satis-basvuru"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"sistemden senetli alım başvurunuzu yapabilirsiniz"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Başvuru yaptım"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Size ulaştımı başvuru"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"onaylandı mı süreciniz"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Başvuru beklemede"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Yazdım"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Yazdı anlamadım bende"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"red olarak sonuçlanmıştır"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"ekran çıkmadı ise onaylanmamıştır"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Anladım"}]"
string query = 
quot;insert into MessageData values(NULL,'{rehberIsmi}','{jsonData}','{DateTime.Now}')";

using (SQLiteConnection conn = new SQLiteConnection(DatabaseInformation.ConnectionString))
{
    try
    {
        conn.Open();

        SQLiteCommand com = new SQLiteCommand(query, conn);
        com.ExecuteNonQuery();

        conn.Close();
    }
    catch (Exception ex)
    {
       MessageBox.Show("Bir hata meydana geldi : " + ex.Message, "Hata", 
       MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}

I am using the above code for data entry into SQLite database, but while getting some string values, I am getting this error:

'SQL logic error near "da": syntax error'

What is the reason ?

Wrong json value : "[
{"avatar":"","position":"right","time":"2021.02.12 12:43:54","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"+905416379800","msg":"Merhabalar Sizlere nasıl yardımcı olabilirim."},
{"avatar":"","position":"left","time":"2021.02.12 12:43:55","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Merhaba"},{"avatar":"","position":"left","time":"2021.02.12 12:44:03","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Senet ile satışınız varmı"},{"avatar":"","position":"left","time":"2021.02.12 12:44:16","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Kanunu mati 125 için"},{"avatar":"","position":"left","time":"2021.02.12 12:44:20","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Bilgi almak istiyorum"},{"avatar":"","position":"left","time":"2021.02.12 12:44:29","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"10 bin peşin versek diğerini"},{"avatar":"","position":"left","time":"2021.02.12 12:44:37","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"12 aya bölsek nasıl olur"},{"avatar":"","position":"right","time":"2021.02.12 13:39:26","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"+905416379800","msg":"https://www.ekuralkan.com/mati-42313 peşin fiyatı 22.353 TL dir. Tüm modellerimizi minimum %25 peşinat ile 36 aya varan taksitler ile alabilirsiniz. https://www.ekuralkan.com/senetli-satis-basvuru\nhttps://blog.ekuralkan.com/\nhttps://www.youtube.com/channel/UCKRIe5B_60bNIR6uSkhxR1g"},{"avatar":"","position":"right","time":"2021.02.12 13:39:36","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"+905416379800","msg":"Sitemiz de vade oranlarını inceleyebilirsiniz"},{"avatar":"","position":"left","time":"2021.12.12 23:52:20","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Bağlantı:\nhttps://www.instagram.com/p/CXTcf_-jRQM/\n\nBunu Instagram'da gördüm..."},{"avatar":"","position":"right","time":"2021.12.12 23:52:20","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Mesajınız için teşekkür ederiz. Mesai saatlerimiz hafta içi 07:00 & 17:00’dir. Mesai saatleri içinde en kısa sürede size cevap vereceğiz."},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"https://www.ekuralkan.com/mati-42313 peşin fiyatı 22.353 TL dir. Tüm modellerimizi minimum %25 peşinat ile 36 aya varan taksitler ile alabilirsiniz. https://www.ekuralkan.com/senetli-satis-basvuru\nhttps://blog.ekuralkan.com/\nhttps://www.youtube.com/channel/UCKRIe5B_60bNIR6uSkhxR1g"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Kolay gelsin"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Senentle satış varmı ?"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Findeks üyeliğiniz varsa senetli alım başvurunuzu yapabiliriz"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Nasıl oluyor o"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"kredi notudur"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"internetten kendiniz üye olmanız gerekiyor"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Onu biliyorum"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Findex üyeliğimiz var zaten de"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Başvuruyu nasıl yapıyoruz"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"37.65 KB","mediaName":"attachment_743","mediaTime":"0\"","localPath":"media\\attachment_743","thumbPath":"media\\attachment_743","delete":"false","type":"photo","identifier":"","msg":"IMG-20211213-WA0001.jpg"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"başvurunuzu buradan yapabiliriz siteden kendiniz de yapabilirsiniz"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Link alabilirmiyim"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Bi türlü bulamadım"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"https://isube.findeks.com/ers/uyelik/bireyselUyelik.xhtml"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Üyeliğim var zaten"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"https://www.ekuralkan.com/senetli-satis-basvuru"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"sistemden senetli alım başvurunuzu yapabilirsiniz"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Başvuru yaptım"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Size ulaştımı başvuru"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"onaylandı mı süreciniz"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Başvuru beklemede"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Yazdım"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Yazdı anlamadım bende"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"red olarak sonuçlanmıştır"},{"avatar":"","position":"right","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"ekran çıkmadı ise onaylanmamıştır"},{"avatar":"","position":"left","time":"1971.01.01 00:00:00","mediaSize":"0 Byte","mediaName":"","mediaTime":"0\"","localPath":"","thumbPath":"","delete":"false","type":"text","identifier":"","msg":"Anladım"}]"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱*していゐ 2025-01-17 22:30:20

如果 rehberIsmi、jsonData 之一包含单引号,您将收到 SQL 语法错误。

就您而言,通过连接字符串来编写 SQL 查询并不是一个好主意。
请使用参数请

command.CommandText = @"insert into MessageData values(NULL,$rehberIsmi,$jsonData,$datetime)";
command.Parameters.AddWithValue("$rehberIsmi", rehberIsmi);
command.Parameters.AddWithValue("$jsonData", jsonData);
command.Parameters.AddWithValue("$datetime", DateTime.Now);

参阅此处的详细信息
https://learn.microsoft.com/en-us/ dotnet/标准/数据/sqlite/参数

You will get SQL syntax error if one of rehberIsmi, jsonData contains single quote.

In your case, composing SQL query by concatenating strings is not a good idea.
please use parameters

command.CommandText = @"insert into MessageData values(NULL,$rehberIsmi,$jsonData,$datetime)";
command.Parameters.AddWithValue("$rehberIsmi", rehberIsmi);
command.Parameters.AddWithValue("$jsonData", jsonData);
command.Parameters.AddWithValue("$datetime", DateTime.Now);

see details here
https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/parameters

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文