473,837 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.OleDbPara meter, Dim paramCustomer As New
OleDb.OleDbPara meter
[snip]
paramDate.Param eterName = "@InvDate"
paramDate.Value = invDate
paramDate.OleDb Type = OleDb.OleDbType .Date
cmdSQL.Paramete rs.Add(paramDat e)

paramCustomer.P arameterName = "@code"
paramCustomer.V alue = cust
cmdSQL.Paramete rs.Add(paramCus tomer)

myOleDbDataAdap ter.Fill(DTResu lt) ******* exception thrown - "Error
converting data type nvarchar to datetime"
....

Stored proc being called is:
CREATE PROCEDURE dbo.bo_GetDisti nctOrders (@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 4460
It isn't for me to help you with your homework/coursework, but consider
this: you must add the parameters to your cmdSQL.Paramete rs 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******** ******@TK2MSFTN GP12.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.OleDbPara meter, Dim paramCustomer As New OleDb.OleDbPara meter
[snip]
paramDate.Param eterName = "@InvDate"
paramDate.Value = invDate
paramDate.OleDb Type = OleDb.OleDbType .Date
cmdSQL.Paramete rs.Add(paramDat e)

paramCustomer.P arameterName = "@code"
paramCustomer.V alue = cust
cmdSQL.Paramete rs.Add(paramCus tomer)

myOleDbDataAdap ter.Fill(DTResu lt) ******* exception thrown - "Error
converting data type nvarchar to datetime"
...

Stored proc being called is:
CREATE PROCEDURE dbo.bo_GetDisti nctOrders (@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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
38595
by: Justin Wong | last post by:
CREATE PROCEDURE dbo.Synchronization_GetNewRecords ( @item varchar(50), @last datetime ) AS SET NOCOUNT ON
3
9400
by: arijitchatterjee123 | last post by:
Hi Group, I am new with SQL Server..I am working with SQL Server 2000. I am storing the date in a nvarchar column of atable.... Now I want to show the data of Weekends..Everything is OK...But the problem is arising with Conversion of nvarchar to date...to identify the weekends...Like..Here DATEVALUE is a nvarchar column...But getting the error..Value of DATEVALUE like dd-mm-yyyy...04-08-2004 ...
4
2340
by: ron | last post by:
Hi, I have class object that i serialize using the System.Xml.Serialization class. Intermittently the object is not getting serialized correctly, using System.Xml.Serialization classes. Therefore the application errors out when deserializing the xml data. It places the some part of the child element
1
17295
by: djozy | last post by:
Please, I want to insert data into SQL Server database. I know for this commmand: SqlCommand myCommand= new SqlCommand("INSERT INTO table (Column1, Column2) " + "Values ('string', 1)", myConnection); ,but how to insert,lets say,a string from textbox1? Or datetime from textbox2? Thank you djozy
0
2134
by: Roman | last post by:
I'm trying to create the form which would allow data entry to the Client table, as well as modification and deletion of existing data rows. For some reason the DataGrid part of functionality stops working when I include data entry fields to the form: I click on Delete or Edit inside of DataGrid and get this error: "Error: Object doesn't support this property or method" If I remove data entry fields from the form - DataGrid allows to...
0
2783
by: Adele | last post by:
Please help, I'm new to SQL and I use a script to import data and when I tried importing data tonight it gave me "error converting data type nvarchar to float". I have no idea what this error means can anyone please show me what I'm doing wrong as I didn't write the script. Please help. select title, as forenames, surname, + 'null' + Addr1 as Address1, Addr2 as Address2, Addr3 as Address3, Addr4 as Address4, Addr5 as Address5,...
8
1731
by: JJ | last post by:
This is slightly OT but .... When testing why my aspx page isn't returning the data as expected I decided to type directly into one of my SQL tables. (The column definitions are below). When I type in data into any of the columns I get this error: "string or binary data will be truncated" I've tried clearing out all the columns but no luck. Even if I just change
6
2566
by: simonakiki | last post by:
hi this is my stored procedure in sql server 2005 this stored procedure select data from database (whith search criteria and sort data by @order_by send by caller and default value is sr_id when i execute this procedure this error will appear "Must declare the scalar variable "@p_result". " and i don't know why please if u can help me
1
1201
by: cmrhema | last post by:
Hi, I want to retrieve the values from store_geofence table where the timeduration exceeds certain interval the procedure is as below CREATE procedure . @regno nvarchar(50), @frmdate nvarchar(50), @todate nvarchar(50),
0
9837
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9682
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10870
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10267
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6998
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5845
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4038
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3123
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.