473,320 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

DateTime DataType Mismatch

I am inserting records in a MS-Access database table. The data type of
one of the columns named *OrderDate* in the DB table is Date/Time.
This is the SQL query I am using to insert the records in the Access
DB table:

===============================
strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (CID, PID, Qty, TotalAmt, ODate)"

oleDbCmd = New OleDbCommand(strSQL, oleDbConn)

With oleDbCmd
.Parameters.AddWithValue("CID", OleDbType.VarChar).Value =
strCartID
.Parameters.AddWithValue("PID", OleDbType.VarChar).Value =
strProductID
.Parameters.AddWithValue("Qty", OleDbType.Integer).Value = iQty
.Parameters.AddWithValue("TotalAmt", OleDbType.Currency).Value =
CInt(iPrice) * CInt(iQty)
.Parameters.AddWithValue("ODate", OleDbType.DBDate).Value =
DateTime.Now
End With
===============================

I want the *OrderDate* column in the Access DB table to have both the
date & the time. The problem is there is no support for a combination
of both date & time in OLEDB. The datatypes supported allow EITHER
date OR time but not both. Hence the above code generates the
following error:

Data type mismatch in criteria expression.

since DateTime.Now gets both the date & the time. If I replace
DateTime.Now in the above code with DateTime.Now.Date, then the above
SQL query executes successfully & inserts records in the DB table but
it adds only the date part in the *OrderDate* column & omits the time
part whereas I want the records under the *OrderDate* column in the DB
table to have both the date as well as the time. Changing the data
type of the last parameter in the above code from OleDbType.DBDate to
OleDbType.Date also doesn't make any difference. The error still
persists.

How do I resolve this issue?

One workaround is to add a new Date/Time data type column in the DB
table & pass another parameter from the ASP.NET code to insert only
the time part but that's a last option if there isn't any other
workaround.

Feb 24 '07 #1
6 3363
Howdy,

I think dbdate is ok. First, you've missedused AddWithValue function which
expects parameter name and it's value (but you are passing DbType enumeration
as value).Second i suspect there is a problem with insert query at
'values(blabla)'. I might be wrong but this form of passing parameters is not
supported by jet provider (ms access) I think this should go like following:

strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (?, ?, ?, ?, ?)"

oleDbCmd = New OleDbCommand(strSQL, oleDbConn)

With oleDbCmd.Parameters
.Add("?", OleDbType.VarChar).Value = strCartID
.Add("?", OleDbType.VarChar).Value = strProductID
.Add("?", OleDbType.Integer).Value = iQty
.Add("?", OleDbType.Currency).Value = CInt(iPrice) * CInt(iQty)
.Add("?", OleDbType.DBDate).Value = DateTime.Now
End With

oledbCmd.ExecuteNonQuery()

Aboive snippet should work. By the way, I'm not sure about the logic you
calculate total price as curency:
CInt(iPrice) * CInt(iQty)
which will always return integer.

Hope this helps
--
Milosz
"rn**@rediffmail.com" wrote:
I am inserting records in a MS-Access database table. The data type of
one of the columns named *OrderDate* in the DB table is Date/Time.
This is the SQL query I am using to insert the records in the Access
DB table:

===============================
strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (CID, PID, Qty, TotalAmt, ODate)"

oleDbCmd = New OleDbCommand(strSQL, oleDbConn)

With oleDbCmd
.Parameters.AddWithValue("CID", OleDbType.VarChar).Value =
strCartID
.Parameters.AddWithValue("PID", OleDbType.VarChar).Value =
strProductID
.Parameters.AddWithValue("Qty", OleDbType.Integer).Value = iQty
.Parameters.AddWithValue("TotalAmt", OleDbType.Currency).Value =
CInt(iPrice) * CInt(iQty)
.Parameters.AddWithValue("ODate", OleDbType.DBDate).Value =
DateTime.Now
End With
===============================

I want the *OrderDate* column in the Access DB table to have both the
date & the time. The problem is there is no support for a combination
of both date & time in OLEDB. The datatypes supported allow EITHER
date OR time but not both. Hence the above code generates the
following error:

Data type mismatch in criteria expression.

since DateTime.Now gets both the date & the time. If I replace
DateTime.Now in the above code with DateTime.Now.Date, then the above
SQL query executes successfully & inserts records in the DB table but
it adds only the date part in the *OrderDate* column & omits the time
part whereas I want the records under the *OrderDate* column in the DB
table to have both the date as well as the time. Changing the data
type of the last parameter in the above code from OleDbType.DBDate to
OleDbType.Date also doesn't make any difference. The error still
persists.

How do I resolve this issue?

One workaround is to add a new Date/Time data type column in the DB
table & pass another parameter from the ASP.NET code to insert only
the time part but that's a last option if there isn't any other
workaround.

Feb 24 '07 #2
On Feb 24, 10:25 pm, Milosz Skalecki [MCAD]
<mily...@DONTLIKESPAMwp.plwrote:
Howdy,

I think dbdate is ok. First, you've missedused AddWithValue function which
expects parameter name and it's value (but you are passing DbType enumeration
as value).Second i suspect there is a problem with insert query at
'values(blabla)'. I might be wrong but this form of passing parameters is not
supported by jet provider (ms access) I think this should go like following:

strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (?, ?, ?, ?, ?)"

oleDbCmd = New OleDbCommand(strSQL, oleDbConn)

With oleDbCmd.Parameters
.Add("?", OleDbType.VarChar).Value = strCartID
.Add("?", OleDbType.VarChar).Value = strProductID
.Add("?", OleDbType.Integer).Value = iQty
.Add("?", OleDbType.Currency).Value = CInt(iPrice) * CInt(iQty)
.Add("?", OleDbType.DBDate).Value = DateTime.Now
End With

oledbCmd.ExecuteNonQuery()

Aboive snippet should work. By the way, I'm not sure about the logic you
calculate total price as curency:
CInt(iPrice) * CInt(iQty)
which will always return integer.

Hope this helps
--
Milosz

"r...@rediffmail.com" wrote:
I am inserting records in a MS-Access database table. The data type of
one of the columns named *OrderDate* in the DB table is Date/Time.
This is the SQL query I am using to insert the records in the Access
DB table:
===============================
strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (CID, PID, Qty, TotalAmt, ODate)"
oleDbCmd = New OleDbCommand(strSQL, oleDbConn)
With oleDbCmd
.Parameters.AddWithValue("CID", OleDbType.VarChar).Value =
strCartID
.Parameters.AddWithValue("PID", OleDbType.VarChar).Value =
strProductID
.Parameters.AddWithValue("Qty", OleDbType.Integer).Value = iQty
.Parameters.AddWithValue("TotalAmt", OleDbType.Currency).Value =
CInt(iPrice) * CInt(iQty)
.Parameters.AddWithValue("ODate", OleDbType.DBDate).Value =
DateTime.Now
End With
===============================
I want the *OrderDate* column in the Access DB table to have both the
date & the time. The problem is there is no support for a combination
of both date & time in OLEDB. The datatypes supported allow EITHER
date OR time but not both. Hence the above code generates the
following error:
Data type mismatch in criteria expression.
since DateTime.Now gets both the date & the time. If I replace
DateTime.Now in the above code with DateTime.Now.Date, then the above
SQL query executes successfully & inserts records in the DB table but
it adds only the date part in the *OrderDate* column & omits the time
part whereas I want the records under the *OrderDate* column in the DB
table to have both the date as well as the time. Changing the data
type of the last parameter in the above code from OleDbType.DBDate to
OleDbType.Date also doesn't make any difference. The error still
persists.
How do I resolve this issue?
One workaround is to add a new Date/Time data type column in the DB
table & pass another parameter from the ASP.NET code to insert only
the time part but that's a last option if there isn't any other
workaround.- Hide quoted text -

- Show quoted text -
Milosz, if I insert records as you have suggested (using '?'), then it
doesn't generate any error & also inserts the record in the DB table
successfully but still only the date part gets inserted & not the time
part in the *OrderDate* column. For e.g. if the current date & time
now is

24/02/2007 6:56:34 PM

then only

24/02/2007 gets inserted in the *OrderDate* column; the time part gets
omitted.

Any other suggestions?

Feb 24 '07 #3
I think both date and time are inserted, but the access shows only date part,
to make sure, run this query

select Format(OrderDate, "YYYY/DD/MM hh:mm:ss") from Cart
--
Milosz
"rn**@rediffmail.com" wrote:
On Feb 24, 10:25 pm, Milosz Skalecki [MCAD]
<mily...@DONTLIKESPAMwp.plwrote:
Howdy,

I think dbdate is ok. First, you've missedused AddWithValue function which
expects parameter name and it's value (but you are passing DbType enumeration
as value).Second i suspect there is a problem with insert query at
'values(blabla)'. I might be wrong but this form of passing parameters is not
supported by jet provider (ms access) I think this should go like following:

strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (?, ?, ?, ?, ?)"

oleDbCmd = New OleDbCommand(strSQL, oleDbConn)

With oleDbCmd.Parameters
.Add("?", OleDbType.VarChar).Value = strCartID
.Add("?", OleDbType.VarChar).Value = strProductID
.Add("?", OleDbType.Integer).Value = iQty
.Add("?", OleDbType.Currency).Value = CInt(iPrice) * CInt(iQty)
.Add("?", OleDbType.DBDate).Value = DateTime.Now
End With

oledbCmd.ExecuteNonQuery()

Aboive snippet should work. By the way, I'm not sure about the logic you
calculate total price as curency:
CInt(iPrice) * CInt(iQty)
which will always return integer.

Hope this helps
--
Milosz

"r...@rediffmail.com" wrote:
I am inserting records in a MS-Access database table. The data type of
one of the columns named *OrderDate* in the DB table is Date/Time.
This is the SQL query I am using to insert the records in the Access
DB table:
===============================
strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (CID, PID, Qty, TotalAmt, ODate)"
oleDbCmd = New OleDbCommand(strSQL, oleDbConn)
With oleDbCmd
.Parameters.AddWithValue("CID", OleDbType.VarChar).Value =
strCartID
.Parameters.AddWithValue("PID", OleDbType.VarChar).Value =
strProductID
.Parameters.AddWithValue("Qty", OleDbType.Integer).Value = iQty
.Parameters.AddWithValue("TotalAmt", OleDbType.Currency).Value =
CInt(iPrice) * CInt(iQty)
.Parameters.AddWithValue("ODate", OleDbType.DBDate).Value =
DateTime.Now
End With
===============================
I want the *OrderDate* column in the Access DB table to have both the
date & the time. The problem is there is no support for a combination
of both date & time in OLEDB. The datatypes supported allow EITHER
date OR time but not both. Hence the above code generates the
following error:
Data type mismatch in criteria expression.
since DateTime.Now gets both the date & the time. If I replace
DateTime.Now in the above code with DateTime.Now.Date, then the above
SQL query executes successfully & inserts records in the DB table but
it adds only the date part in the *OrderDate* column & omits the time
part whereas I want the records under the *OrderDate* column in the DB
table to have both the date as well as the time. Changing the data
type of the last parameter in the above code from OleDbType.DBDate to
OleDbType.Date also doesn't make any difference. The error still
persists.
How do I resolve this issue?
One workaround is to add a new Date/Time data type column in the DB
table & pass another parameter from the ASP.NET code to insert only
the time part but that's a last option if there isn't any other
workaround.- Hide quoted text -
- Show quoted text -

Milosz, if I insert records as you have suggested (using '?'), then it
doesn't generate any error & also inserts the record in the DB table
successfully but still only the date part gets inserted & not the time
part in the *OrderDate* column. For e.g. if the current date & time
now is

24/02/2007 6:56:34 PM

then only

24/02/2007 gets inserted in the *OrderDate* column; the time part gets
omitted.

Any other suggestions?

Feb 24 '07 #4
On Feb 25, 12:16 am, Milosz Skalecki [MCAD]
<mily...@DONTLIKESPAMwp.plwrote:
I think both date and time are inserted, but the access shows only date part,
to make sure, run this query

select Format(OrderDate, "YYYY/DD/MM hh:mm:ss") from Cart
--
Milosz

"r...@rediffmail.com" wrote:
On Feb 24, 10:25 pm, Milosz Skalecki [MCAD]
<mily...@DONTLIKESPAMwp.plwrote:
Howdy,
I think dbdate is ok. First, you've missedused AddWithValue function which
expects parameter name and it's value (but you are passing DbType enumeration
as value).Second i suspect there is a problem with insert query at
'values(blabla)'. I might be wrong but this form of passing parameters is not
supported by jet provider (ms access) I think this should go like following:
strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (?, ?, ?, ?, ?)"
oleDbCmd = New OleDbCommand(strSQL, oleDbConn)
With oleDbCmd.Parameters
.Add("?", OleDbType.VarChar).Value = strCartID
.Add("?", OleDbType.VarChar).Value = strProductID
.Add("?", OleDbType.Integer).Value = iQty
.Add("?", OleDbType.Currency).Value = CInt(iPrice) * CInt(iQty)
.Add("?", OleDbType.DBDate).Value = DateTime.Now
End With
oledbCmd.ExecuteNonQuery()
Aboive snippet should work. By the way, I'm not sure about the logic you
calculate total price as curency:
CInt(iPrice) * CInt(iQty)
which will always return integer.
Hope this helps
--
Milosz
"r...@rediffmail.com" wrote:
I am inserting records in a MS-Access database table. The data type of
one of the columns named *OrderDate* in the DB table is Date/Time.
This is the SQL query I am using to insert the records in the Access
DB table:
===============================
strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (CID, PID, Qty, TotalAmt, ODate)"
oleDbCmd = New OleDbCommand(strSQL, oleDbConn)
With oleDbCmd
.Parameters.AddWithValue("CID", OleDbType.VarChar).Value =
strCartID
.Parameters.AddWithValue("PID", OleDbType.VarChar).Value =
strProductID
.Parameters.AddWithValue("Qty", OleDbType.Integer).Value = iQty
.Parameters.AddWithValue("TotalAmt", OleDbType.Currency).Value =
CInt(iPrice) * CInt(iQty)
.Parameters.AddWithValue("ODate", OleDbType.DBDate).Value =
DateTime.Now
End With
===============================
I want the *OrderDate* column in the Access DB table to have both the
date & the time. The problem is there is no support for a combination
of both date & time in OLEDB. The datatypes supported allow EITHER
date OR time but not both. Hence the above code generates the
following error:
Data type mismatch in criteria expression.
since DateTime.Now gets both the date & the time. If I replace
DateTime.Now in the above code with DateTime.Now.Date, then the above
SQL query executes successfully & inserts records in the DB table but
it adds only the date part in the *OrderDate* column & omits the time
part whereas I want the records under the *OrderDate* column in the DB
table to have both the date as well as the time. Changing the data
type of the last parameter in the above code from OleDbType.DBDate to
OleDbType.Date also doesn't make any difference. The error still
persists.
How do I resolve this issue?
One workaround is to add a new Date/Time data type column in the DB
table & pass another parameter from the ASP.NET code to insert only
the time part but that's a last option if there isn't any other
workaround.- Hide quoted text -
- Show quoted text -
Milosz, if I insert records as you have suggested (using '?'), then it
doesn't generate any error & also inserts the record in the DB table
successfully but still only the date part gets inserted & not the time
part in the *OrderDate* column. For e.g. if the current date & time
now is
24/02/2007 6:56:34 PM
then only
24/02/2007 gets inserted in the *OrderDate* column; the time part gets
omitted.
Any other suggestions?- Hide quoted text -

- Show quoted text -
When I executed your query, Milosz, the record under the *OrderDate*
column showed the date part but it showed the time part as 00:00:00
like for e.g.

24/02/2007 00:00:00

What next??

Feb 24 '07 #5
On Feb 25, 1:31 am, r...@rediffmail.com wrote:
On Feb 25, 12:16 am, Milosz Skalecki [MCAD]

<mily...@DONTLIKESPAMwp.plwrote:
I think both date and time are inserted, but the access shows only date part,
to make sure, run this query
select Format(OrderDate, "YYYY/DD/MM hh:mm:ss") from Cart
--
Milosz
"r...@rediffmail.com" wrote:
On Feb 24, 10:25 pm, Milosz Skalecki [MCAD]
<mily...@DONTLIKESPAMwp.plwrote:
Howdy,
I think dbdate is ok. First, you've missedused AddWithValue function which
expects parameter name and it's value (but you are passing DbType enumeration
as value).Second i suspect there is a problem with insert query at
'values(blabla)'. I might be wrong but this form of passing parameters is not
supported by jet provider (ms access) I think this should go like following:
strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (?, ?, ?, ?, ?)"
oleDbCmd = New OleDbCommand(strSQL, oleDbConn)
With oleDbCmd.Parameters
.Add("?", OleDbType.VarChar).Value = strCartID
.Add("?", OleDbType.VarChar).Value = strProductID
.Add("?", OleDbType.Integer).Value = iQty
.Add("?", OleDbType.Currency).Value = CInt(iPrice) * CInt(iQty)
.Add("?", OleDbType.DBDate).Value = DateTime.Now
End With
oledbCmd.ExecuteNonQuery()
Aboive snippet should work. By the way, I'm not sure about the logic you
calculate total price as curency:
CInt(iPrice) * CInt(iQty)
which will always return integer.
Hope this helps
--
Milosz
"r...@rediffmail.com" wrote:
I am inserting records in a MS-Access database table. The data type of
one of the columns named *OrderDate* in the DB table is Date/Time.
This is the SQL query I am using to insert the records in the Access
DB table:
===============================
strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (CID, PID, Qty, TotalAmt, ODate)"
oleDbCmd = New OleDbCommand(strSQL, oleDbConn)
With oleDbCmd
.Parameters.AddWithValue("CID", OleDbType.VarChar).Value =
strCartID
.Parameters.AddWithValue("PID", OleDbType.VarChar).Value =
strProductID
.Parameters.AddWithValue("Qty", OleDbType.Integer).Value = iQty
.Parameters.AddWithValue("TotalAmt", OleDbType.Currency).Value =
CInt(iPrice) * CInt(iQty)
.Parameters.AddWithValue("ODate", OleDbType.DBDate).Value =
DateTime.Now
End With
===============================
I want the *OrderDate* column in the Access DB table to have both the
date & the time. The problem is there is no support for a combination
of both date & time in OLEDB. The datatypes supported allow EITHER
date OR time but not both. Hence the above code generates the
following error:
Data type mismatch in criteria expression.
since DateTime.Now gets both the date & the time. If I replace
DateTime.Now in the above code with DateTime.Now.Date, then the above
SQL query executes successfully & inserts records in the DB table but
it adds only the date part in the *OrderDate* column & omits the time
part whereas I want the records under the *OrderDate* column in the DB
table to have both the date as well as the time. Changing the data
type of the last parameter in the above code from OleDbType.DBDate to
OleDbType.Date also doesn't make any difference. The error still
persists.
How do I resolve this issue?
One workaround is to add a new Date/Time data type column in the DB
table & pass another parameter from the ASP.NET code to insert only
the time part but that's a last option if there isn't any other
workaround.- Hide quoted text -
- Show quoted text -
Milosz, if I insert records as you have suggested (using '?'), then it
doesn't generate any error & also inserts the record in the DB table
successfully but still only the date part gets inserted & not the time
part in the *OrderDate* column. For e.g. if the current date & time
now is
24/02/2007 6:56:34 PM
then only
24/02/2007 gets inserted in the *OrderDate* column; the time part gets
omitted.
Any other suggestions?- Hide quoted text -
- Show quoted text -

When I executed your query, Milosz, the record under the *OrderDate*
column showed the date part but it showed the time part as 00:00:00
like for e.g.

24/02/2007 00:00:00

What next??- Hide quoted text -

- Show quoted text -
Milosz, the following inserts both date & time in the Access DB
column:

..Parameters.AddWithValue("?", DateTime.Now.ToString)

Even the obsolete Add function can be used like this:

..Parameters.Add("?", DbType.DateTime).Value = DateTime.Now.ToString

Strangely, in both cases, omitting the ToString function generates the

Data type mismatch in criteria expression.

error though the column in the Access DB table is of type Date/Time!

Any idea why?

Feb 25 '07 #6
Howdy,

Maybe something else generates mentioned mismatch exception. Could you give
me all the columns names with type please?
--
Milosz
"rn**@rediffmail.com" wrote:
On Feb 25, 1:31 am, r...@rediffmail.com wrote:
On Feb 25, 12:16 am, Milosz Skalecki [MCAD]

<mily...@DONTLIKESPAMwp.plwrote:
I think both date and time are inserted, but the access shows only date part,
to make sure, run this query
select Format(OrderDate, "YYYY/DD/MM hh:mm:ss") from Cart
--
Milosz
"r...@rediffmail.com" wrote:
On Feb 24, 10:25 pm, Milosz Skalecki [MCAD]
<mily...@DONTLIKESPAMwp.plwrote:
Howdy,
I think dbdate is ok. First, you've missedused AddWithValue function which
expects parameter name and it's value (but you are passing DbType enumeration
as value).Second i suspect there is a problem with insert query at
'values(blabla)'. I might be wrong but this form of passing parameters is not
supported by jet provider (ms access) I think this should go like following:
strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (?, ?, ?, ?, ?)"
oleDbCmd = New OleDbCommand(strSQL, oleDbConn)
With oleDbCmd.Parameters
.Add("?", OleDbType.VarChar).Value = strCartID
.Add("?", OleDbType.VarChar).Value = strProductID
.Add("?", OleDbType.Integer).Value = iQty
.Add("?", OleDbType.Currency).Value = CInt(iPrice) * CInt(iQty)
.Add("?", OleDbType.DBDate).Value = DateTime.Now
End With
oledbCmd.ExecuteNonQuery()
Aboive snippet should work. By the way, I'm not sure about the logic you
calculate total price as curency:
CInt(iPrice) * CInt(iQty)
which will always return integer.
Hope this helps
--
Milosz
"r...@rediffmail.com" wrote:
I am inserting records in a MS-Access database table. The data type of
one of the columns named *OrderDate* in the DB table is Date/Time.
This is the SQL query I am using to insert the records in the Access
DB table:
===============================
strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (CID, PID, Qty, TotalAmt, ODate)"
oleDbCmd = New OleDbCommand(strSQL, oleDbConn)
With oleDbCmd
.Parameters.AddWithValue("CID", OleDbType.VarChar).Value =
strCartID
.Parameters.AddWithValue("PID", OleDbType.VarChar).Value =
strProductID
.Parameters.AddWithValue("Qty", OleDbType.Integer).Value = iQty
.Parameters.AddWithValue("TotalAmt", OleDbType.Currency).Value =
CInt(iPrice) * CInt(iQty)
.Parameters.AddWithValue("ODate", OleDbType.DBDate).Value =
DateTime.Now
End With
===============================
I want the *OrderDate* column in the Access DB table to have both the
date & the time. The problem is there is no support for a combination
of both date & time in OLEDB. The datatypes supported allow EITHER
date OR time but not both. Hence the above code generates the
following error:
Data type mismatch in criteria expression.
since DateTime.Now gets both the date & the time. If I replace
DateTime.Now in the above code with DateTime.Now.Date, then the above
SQL query executes successfully & inserts records in the DB table but
it adds only the date part in the *OrderDate* column & omits the time
part whereas I want the records under the *OrderDate* column in the DB
table to have both the date as well as the time. Changing the data
type of the last parameter in the above code from OleDbType.DBDate to
OleDbType.Date also doesn't make any difference. The error still
persists.
How do I resolve this issue?
One workaround is to add a new Date/Time data type column in the DB
table & pass another parameter from the ASP.NET code to insert only
the time part but that's a last option if there isn't any other
workaround.- Hide quoted text -
- Show quoted text -
Milosz, if I insert records as you have suggested (using '?'), then it
doesn't generate any error & also inserts the record in the DB table
successfully but still only the date part gets inserted & not the time
part in the *OrderDate* column. For e.g. if the current date & time
now is
24/02/2007 6:56:34 PM
then only
24/02/2007 gets inserted in the *OrderDate* column; the time part gets
omitted.
Any other suggestions?- Hide quoted text -
- Show quoted text -
When I executed your query, Milosz, the record under the *OrderDate*
column showed the date part but it showed the time part as 00:00:00
like for e.g.

24/02/2007 00:00:00

What next??- Hide quoted text -

- Show quoted text -

Milosz, the following inserts both date & time in the Access DB
column:

..Parameters.AddWithValue("?", DateTime.Now.ToString)

Even the obsolete Add function can be used like this:

..Parameters.Add("?", DbType.DateTime).Value = DateTime.Now.ToString

Strangely, in both cases, omitting the ToString function generates the

Data type mismatch in criteria expression.

error though the column in the Access DB table is of type Date/Time!

Any idea why?

Feb 25 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stephen Briley | last post by:
For some reason, my posts are scrubbed as attachments. Lets hope that sending from the yahoo account works. I'm new to Python and I'm trying to do some database work with MS Access, but I can't...
2
by: Steve Briley | last post by:
I'm new to Python and I'm trying to do some database work with MS Access, but I can't seem to get around a "datatype mismatch error".&nbsp; Here's an example table that I'm working with... ...
1
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
0
by: vijayalakshmi.venkataraman | last post by:
Hello, I have a .NET client that accesses a Java webservice. Let me first say that the client stub I got generated from the wsdl was incomplete and had to make changes to it manually to make it...
11
by: Matt F | last post by:
I'm trying to do something that seems like it should be pretty simple, but haven't found a solution. I am trying to add a datacolumn to a datatable that adds or subtracts a number of days based on...
2
by: chirag1989 | last post by:
I m havin an error of datatype mismatch actual here i m askin user to input the code in text box and then searchin the record havin that code in database the problem is the code field Bnum is of...
9
by: rscheinberg | last post by:
I am working in Access 2007 attempting to grab 2 characters from a text field named ProjectNumber. After determining what 2 digits to add in front to make it a year, I need to do that. I have done...
14
by: rscheinberg | last post by:
I am working in Access 2007 attempting to grab 2 characters from a text field named ProjectNumber. After determining what 2 digits to add in front to make it a year, I need to do that. I have done...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.