469,950 Members | 1,895 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Error converting data type nvarchar to datetime - Please help

this seems to be an SQL Server error but I cant work out how it is occuring.
Itr is also after 3am and I cant keep working but need to demo by tomorrow.
TIA. The code is:
Private Sub myMethod(ByVal cust As String, ByVal invDate As Date)
[snip]
Dim paramDate As New OleDb.OleDbParameter, Dim paramCustomer As New
OleDb.OleDbParameter
[snip]
paramDate.ParameterName = "@InvDate"
paramDate.Value = invDate
paramDate.OleDbType = OleDb.OleDbType.Date
cmdSQL.Parameters.Add(paramDate)

paramCustomer.ParameterName = "@code"
paramCustomer.Value = cust
cmdSQL.Parameters.Add(paramCustomer)

myOleDbDataAdapter.Fill(DTResult) ******* exception thrown - "Error
converting data type nvarchar to datetime"
....

Stored proc being called is:
CREATE PROCEDURE dbo.bo_GetDistinctOrders (@code as nvarchar(8), @invdate as
datetime) AS
SELECT prodcode, qty, price, comment
FROM Orders
where custcode = @code and InvDate = @InvDate

GO (Note, InvDate in the Orders table is a datetime:-)
Nov 20 '05 #1
1 4122
It isn't for me to help you with your homework/coursework, but consider
this: you must add the parameters to your cmdSQL.Parameters in the order in
which SQL server requires them to be passed in (in your case char then
date).

"Andrew Baker" <no@spam.com> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
this seems to be an SQL Server error but I cant work out how it is occuring. Itr is also after 3am and I cant keep working but need to demo by tomorrow. TIA. The code is:
Private Sub myMethod(ByVal cust As String, ByVal invDate As Date)
[snip]
Dim paramDate As New OleDb.OleDbParameter, Dim paramCustomer As New OleDb.OleDbParameter
[snip]
paramDate.ParameterName = "@InvDate"
paramDate.Value = invDate
paramDate.OleDbType = OleDb.OleDbType.Date
cmdSQL.Parameters.Add(paramDate)

paramCustomer.ParameterName = "@code"
paramCustomer.Value = cust
cmdSQL.Parameters.Add(paramCustomer)

myOleDbDataAdapter.Fill(DTResult) ******* exception thrown - "Error
converting data type nvarchar to datetime"
...

Stored proc being called is:
CREATE PROCEDURE dbo.bo_GetDistinctOrders (@code as nvarchar(8), @invdate as datetime) AS
SELECT prodcode, qty, price, comment
FROM Orders
where custcode = @code and InvDate = @InvDate

GO (Note, InvDate in the Orders table is a datetime:-)

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by arijitchatterjee123 | last post: by
4 posts views Thread by ron | last post: by
1 post views Thread by djozy | last post: by
8 posts views Thread by JJ | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.