qasanov
qasanov

Reputation: 437

dataset datetime format problem

I am having a problem with datetime format in a dataset.

In the database date format is:10/5/2009 10:10:10

but i get an error:FormatException, when attempting to fill the DataSet:

string query = "SELECT * FROM teklif"; 
c.db = new SQLiteDataAdapter(query, c.con); 
c.db.Fill(ds);  // Error Here...
dt = ds.Tables[0];

How do I resolve this issue?

Upvotes: 0

Views: 1378

Answers (1)

mcauthorn
mcauthorn

Reputation: 598

It would appear that you are not initializing the adapter right.

 MySQLiteConn = new SQLiteConnection("Data Source=" + fileName +
                    "; Compress = TRUE;");
SQLiteCommand cmd = MySQLiteConn.CreateCommand();


            SQLiteDataAdapter dr = new SQLiteDataAdapter(cmd);
            SQLiteDataAdapter adapter;
            try
            {
                cmd.CommandText = "SELECT * FROM teklif";
                adapter = new SQLiteDataAdapter(cmd);
                dt = new DataTable();
                adapter.Fill(dt);                    
            }
            catch (Exception ex)
            {
                Console.WriteLine("Retrieval of Table Failed. " + ex.Message);
                return -1;
            }

If that fails then make sure that is the correct table name in your sqlite database.

Upvotes: 1

Related Questions