DateTime to OleDbType (MS Access)

  • Thread starter Thread starter Flynn Arrowstarr
  • Start date Start date
F

Flynn Arrowstarr

Hi, I'm writing an application using an Access 2000 database. I am wanting
to store the date and time of each record in separate fields in my data
table. The problem is, what OleDbType do I need to use? There's Date,
DBDate, DBTime, and DBTimeStamp. So, here's my table structure:

Col1 AutoNumber (Primary Key)
Col2 DateTime (Date field)
Col3 DateTime (Time field)

So, in my Update method, I'm trying to create a Parameter for the SQL
statement. Here's the code:

sqlCmd.Parameters.Add(new OleDbParameter("@Col1", OleDbType.Integer));
sqlCmd.Parameters.Add(new OleDbParameter("@Col2", OleDbType.???));
sqlCmd.Parameters.Add(new OleDbParameter("@Col3", OleDbType.???));

What types do I need to use to store the Date and Time in Col2 and Col3
respectively? The date and time values are being passed in as DateTime types
from the .NET Framework.

Flynn
 
¤ Hi, I'm writing an application using an Access 2000 database. I am wanting
¤ to store the date and time of each record in separate fields in my data
¤ table. The problem is, what OleDbType do I need to use? There's Date,
¤ DBDate, DBTime, and DBTimeStamp. So, here's my table structure:
¤
¤ Col1 AutoNumber (Primary Key)
¤ Col2 DateTime (Date field)
¤ Col3 DateTime (Time field)
¤
¤ So, in my Update method, I'm trying to create a Parameter for the SQL
¤ statement. Here's the code:
¤
¤ sqlCmd.Parameters.Add(new OleDbParameter("@Col1", OleDbType.Integer));
¤ sqlCmd.Parameters.Add(new OleDbParameter("@Col2", OleDbType.???));
¤ sqlCmd.Parameters.Add(new OleDbParameter("@Col3", OleDbType.???));
¤
¤ What types do I need to use to store the Date and Time in Col2 and Col3
¤ respectively? The date and time values are being passed in as DateTime types
¤ from the .NET Framework.

Access supports a Date/Time column data type and that would be System.Data.OleDb.OleDbType.Date.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top