Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, 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:
C#
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;

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"
Posted
Updated 11-Jan-15 9:58am
v3
Comments
Zoltán Zörgő 11-Jan-15 16:00pm    
Are you sure your database is in format version 3?
SrgjanX 11-Jan-15 16:02pm    
i dont really know what is version 3 but its definitely sqlite3, if thats what it means :D
Zoltán Zörgő 11-Jan-15 16:19pm    
Open db in any hex editor. It should start with: SQLite format 3
ZurdoDev 11-Jan-15 22:01pm    
Please post as solution. It wasn't the right format and you're response led the OP there.
Zoltán Zörgő 11-Jan-15 16:40pm    
Well?

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900