mardi 5 avril 2016

How to get date into a string variable from sqlite database?

I want to take date from a sqlite database. Table column name is "date" and column type is date.

        SQLiteCommand sqlite_cmd;
        SQLiteDataReader sqlite_datareader;
        sqlite_conn = new SQLiteConnection(sConnectionString);
        sqlite_conn.Open();
        sqlite_cmd = sqlite_conn.CreateCommand();

        sqlite_cmd.CommandText = "Select * from prework where pid = " + iProjectID + " and chainage = " + fChainage + ";";

        try
        {
            sqlite_datareader = sqlite_cmd.ExecuteReader();
            while (sqlite_datareader.Read())
            {
                String str = sqlite_datareader["date"].ToString();
            }
        }
        catch
        {
            return;
        }

I want to get the date in str variable.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire