gpt4 book ai didi

c# - 我们可以在C#中使用点命令(SQlite的特殊命令)

转载 作者:行者123 更新时间:2023-12-02 04:21:29 25 4
gpt4 key购买 nike

string batFilePath = @"D:\mockforbat.bat";
if (!File.Exists(batFilePath))
{
using (FileStream fs = File.Create(batFilePath))
{
fs.Close();
}
}

using (StreamWriter sw = new StreamWriter(batFilePath))
{
sw.WriteLine(@".mode csv");
sw.WriteLine(@".import D:/Ashif/SQLITE/Bulk.csv excelUpload");
}


SQLiteCommand cmd = new SQLiteCommand(conn);

cmd.CommandText = ".read D:/mockforbar.bat";
SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);

当我执行此命令时,我收到此错误。

An unhandled exception of type 'System.Data.SQLite.SQLiteException' occurred in System.Data.SQLite.dll

Additional information: SQL logic error

near ".": syntax error

最佳答案

不,您不能使用 the Sqlite command-line commands (如 .read.import)使用 SQLiteCommand

您需要使用 System.Diagnostics.Process 调用命令行 sqlitesqlite3 程序来运行这些命令。

关于c# - 我们可以在C#中使用点命令(SQlite的特殊命令),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58654547/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com