c# - c# 表未显示在 .db3 文件中
问题描述
我这个月才开始使用 c#,当我尝试创建一个新的数据库文件 (.db3) 时遇到了这个问题,该表已创建但当我用 sqlite studio 打开它时没有显示。当我再次尝试时,系统说该表已经存在,但是当我打开 .db3 文件时,该表不在其中,这是我的代码。
SQLiteConnection.CreateFile("C:\\Users\\user\\Desktop\\newTable.db3");
SQLiteConnection createnew = new SQLiteConnection("Data Source=newTable.db3; Version=3;");
createnew.Open();
string newtbl1 = "CREATE TABLE newtest (ID varchar(32) not null, frameId integer not null, posAttrib varchar(128) not null, attrib varchar(64), name varchar(200))";
SQLiteCommand command = new SQLiteCommand(newtbl1, createnew);
command.ExecuteNonQuery();
我试图在谷歌上进行一些搜索,但我一无所获。我不知道如何解决它并且在 c# 方面的知识非常有限,谁能给我一个提示或任何我可以搜索的关键字?非常感谢!
解决方案
那么,如果您打开 SQLiteConnection,您是打开刚刚在桌面上创建的那个,还是打开任何工作目录中的那个?
试试这种方式:
string dbfile = @"C:\Users\user\Desktop\newTable.db3";
SQLiteConnection.CreateFile(dbfile);
SQLiteConnection createnew = new SQLiteConnection($"Data Source={dbfile}; Version=3;");
createnew.Open();
string newtbl1 = "CREATE TABLE newtest (ID varchar(32) not null, frameId integer not null, posAttrib varchar(128) not null, attrib varchar(64), name varchar(200))";
SQLiteCommand command = new SQLiteCommand(newtbl1, createnew);
command.ExecuteNonQuery();
推荐阅读
- javascript - How to open the concrete article in Zendesk Widget?
- angular - Cannot assign to read only property '0' of object '[object Array] primeng
- flutter - 我想要一个在关闭后自行打开的 AlertDialog
- google-cloud-platform - 如何解决 terraform 错误“等待状态变为‘完成:真’时超时(最后状态:‘完成:假’,超时:10m0s)”?
- python - How to filter keypoint matches in OpenCV?
- jmeter - 如何从以下针对 jmeter 中的验证链接收到的 json 响应中提取 Id 和令牌
- flutter - 从最近的应用程序重新打开后 Flutter 应用程序无法运行
- react-native - 在 React Native 中为视图设置动画
- javascript - 如何使用天气命令修复错误
- ios - NSZone.h 中的未知类型名称“NS_ASSUME_NONNULL_BEGIN”