c#和sqlite数据库出错 [英] Error with c# and sqlite database

查看:92
本文介绍了c#和sqlite数据库出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我一直在使用mysql进行数据库,但我必须学习一些本地更快的数据库,所以我找到了sqlite,我不知道sqlite如何工作所以这就是为什么我在这里,基本上我只是做了一个快速的数据库,我命名它'data.db',现在使用c#我需要读取里面的数据,但我这样读了:

utill now i always been using mysql for database, but i must learn some local faster database so i found sqlite, i dont know how sqlite works so thats why im here, basically i just made a quick database and i named it 'data.db', and now using c# i need to read the data that is inside but i read it like this:

SQLiteConnection m_dbConnection;
            m_dbConnection = new SQLiteConnection("Data Source=data.db;Version=3;");
            m_dbConnection.Open();

            string sql = "select Question from questions where QuestionID = 1;";
            SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
            SQLiteDataReader reader = command.ExecuteReader();
            //while (reader.Read())
                txtResponse.Text = "1";
                //returnpoint = reader["Question"].ToString();
            //txtResponse.Text = returnpoint;



sql命令语法是正确的,因为我在mysql中使用相同的。

但它显示问题,这里是图片了解更多信息。

顺便提前谢谢,我也忘了提到我引用了System.Data.SQLite.dll


the sql command syntax is correct because i use the same in mysql.
but it shows problem, here is a picture for more info.
btw thanks in advance, also i forgot to mention that i have referenced "System.Data.SQLite.dll"

推荐答案

错误实际上非常明确,说明该文件不是数据库。我在评论中看到你的工作。很高兴看到这一点。
The error was actually pretty clear stating that the file was not a database. I see in the comments you got it working. Glad to see that.


这篇关于c#和sqlite数据库出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆