Hello, I can not get values ​​from SQLite database

using System.Data.SQLite; using System.Windows; using System.Data; using System.Data.SqlClient; 

... DataTable datatabl = new DataTable ();

  public void Zanesti_dannie_v_tablicy() { SQLiteConnection connection = new SQLiteConnection(string.Format("Data Source={0};", databaseName)); try { connection.Open(); string sqlCommand = "SELECT * FROM test "; SQLiteCommand mycommand = new SQLiteCommand(sqlCommand, connection); SQLiteDataReader reader = mycommand.ExecuteReader(); datatabl.Load(reader); reader.Close(); connection.Close(); } catch (Exception) { MessageBox.Show("Оёёй!"); } } ------------------------------- Студия выдала вообще какой-то бред "Строка не распознана как действительное значение DateTime". строка( datatabl.Load(reader); )Хотя я взял это из примера для MSSql где это работало. 

What does the DateTime have to do with this? Please tell me how to read from the database and put it in the table. thank

  • four
    omaygadbl! the terrible name of the method Zanesti_dannie_v_tablicy () - Ivan Navoznov
  • I also do not advise you to wrap everything in one Try-Catch block. - Ivan Navoznov
  • Yes, it is better then to call the method in Russian. - Chad
  • And in datatabl there are columns DateTime? - Chad
  • Ahhh ... CHAD you are a genius. Yes. There is a table, but I didn’t understand what was happening. Only now, then, the second question, and what to do with it? Thank you - Rakzin Roman

2 answers 2

The problem is that SQLite has no date column format. Here either the trouble in the data (can not parse).

Or explicitly indicate the column. This kind of treats. If I remember a beautiful solution to this problem (it was a couple of years ago) - I will write.

Try to wrap a column with a date into something that will be interpreted as a date in the query. The trouble is clearly that the adapter reads null as "", and this cannot convert to DateTime.

  • Thanks, in general, for reasons I do not understand, earned. I copied everything new to the project under .Net4 (and before that was .net4.5). Thank. Sori, that powdered brains. - Rakzin Roman

See an example here.

  • Does Devart have this own database access database? Is it any different from the usual? - Rakzin Roman