DateTime to OleDbType (MS Access)

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
 
P

Paul Clement

¤ 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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top