neoice
asked on
Convert date from mm/dd/yyyy to dd/mm/yyyy in Visual Basic.net
Hi,
I receive the following error at run time:
"error converting datatype varchar to datetime"
I imagine it's because it is trying to insert 10/16/2008 into my SQL DB wich is set to UK language.
Dim MyConn As SqlConnection
Dim MyCmd As SqlCommand
Dim MyCmd1 As SqlCommand
Dim currentdate As Date
currentdate = Date.Now
Dim connectionstring As String = ConfigurationManager.Conne ctionStrin gs("conn") .Connectio nString
MyConn = New SqlConnection(connectionst ring)
MyConn.Open()
LblMessage.Text = currentdate
MyCmd = New SqlCommand("execute tblstock_duplicateserial @serialnumber ='" & RTBCode.Text & "', @qty ='" & RTBQty.Text & "', @category='" & RCBCategory.Text & "', @items='" & RCBItem.Text & "', @location='" & RCBLocation.Text & "', @orderno='" & RCBPO.Text & "', @description='" & RTBDescription.Text & "',@lastactivitydate='" & currentdate & "'", MyConn)
MyCmd.ExecuteScalar()
I receive the following error at run time:
"error converting datatype varchar to datetime"
I imagine it's because it is trying to insert 10/16/2008 into my SQL DB wich is set to UK language.
Dim MyConn As SqlConnection
Dim MyCmd As SqlCommand
Dim MyCmd1 As SqlCommand
Dim currentdate As Date
currentdate = Date.Now
Dim connectionstring As String = ConfigurationManager.Conne
MyConn = New SqlConnection(connectionst
MyConn.Open()
LblMessage.Text = currentdate
MyCmd = New SqlCommand("execute tblstock_duplicateserial @serialnumber ='" & RTBCode.Text & "', @qty ='" & RTBQty.Text & "', @category='" & RCBCategory.Text & "', @items='" & RCBItem.Text & "', @location='" & RCBLocation.Text & "', @orderno='" & RCBPO.Text & "', @description='" & RTBDescription.Text & "',@lastactivitydate='" & currentdate & "'", MyConn)
MyCmd.ExecuteScalar()
ASKER
Hi,
After hours of research on this I have found the answer!!!!!!!!!!!!!!
The SA account I used to send the data had the language set to english. Setting this to British resolved my problem!!!!!!!!!!
As I have solved my own problem, I am willing to give the points to anybody that can convert the above SQL to use parameters, proving I am allowed to do this?
Cheers
After hours of research on this I have found the answer!!!!!!!!!!!!!!
The SA account I used to send the data had the language set to english. Setting this to British resolved my problem!!!!!!!!!!
As I have solved my own problem, I am willing to give the points to anybody that can convert the above SQL to use parameters, proving I am allowed to do this?
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Good memory!
http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson06.aspx