0

enter image description hereI want to open a .data file. I use SQLite Studio. The file is opened normally. But if you try to print data into DataGrid in the WInForms application, but it crashes out that it's not a database file

string connString = @"Data Source=AdLoc.data; Version=3";
const string query = "SELECT * FROM Person";
DataSet ds = new DataSet();

SQLiteConnection connection = new SQLiteConnection(connString);
SQLiteCommand command = new SQLiteCommand(query, connection);
connection.Open();
using (SQLiteDataAdapter adapter = new SQLiteDataAdapter(command))
{
   adapter.Fill(ds);
}


dataGridView1.DataSource = ds.Tables[0];    
Саске
  • 190
  • 3
  • 12
  • have you tried renaming the file to ***.db ?? SQLite should not actually care about the files extension - see here https://stackoverflow.com/questions/808499/what-is-the-best-extension-name-sqlite-database-files – Sancho Panza Jan 22 '18 at 13:11
  • 1
    What is the exact exception? – Alex K. Jan 22 '18 at 13:15
  • Add the exception and in which line it happens to your post. By the way check you already give the correct path to your database full/relative path! – Bassem Jan 22 '18 at 13:23
  • 1
    Don't post screenshots of errors. Post the error text itself. – Uwe Keim Jan 22 '18 at 13:55
  • @BassemAkl - Educated guess says that if the file path was incorrect, it'd be throwing some sort of "File not found" exception. Best guess is the source file isn't formatted in a manner that SQLite can correctly deal with. – user2366842 Jan 22 '18 at 14:04

0 Answers0