Error converting data type nvarchar to datetime - Please help

A

Andrew Baker

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:)
 
R

Robin Tucker

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

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