I have a table that contains datetime fields, i want to retrieve that date and display it on a datetime picker on c#, how can i achieve this?
reader = oleDbCmd.ExecuteReader();
reader.Read();
DTPicker.Value += reader[1];
reader.Close();
the date is on my second column of the table.
Here is an example of how to read data from a OleDbDataReader:
private static void ReadData(string connectionString)
{
string queryString = "SELECT OrderID, CustomerID FROM Orders";
using (OracleConnection connection = new OracleConnection(connectionString))
{
OracleCommand command = new OracleCommand(queryString, connection);
connection.Open();
OracleDataReader reader;
reader = command.ExecuteReader();
// Always call Read before accessing data.
while (reader.Read())
{
Console.WriteLine(reader.GetInt32(0) + ", " + reader.GetString(1));
}
// Always call Close when done reading.
reader.Close();
}
}
Instead of using reader.GetInt(0)
you would then use Convert.ToDateTime(reader[0])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.