Click here to Skip to main content
15,885,119 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
Below is my update query

VB
Update OrderMaster set OrderFrmType='G',OrderDate='" & dtpOrderDate.SelectedDate & "',SMGIDRef='" & j & "',MDIDRef='" & k & "', Remark='" & txtRemark.Text & "', AIDAgencyRef='" & l & "' where OrderFormNo='" & cmbOrderNo.Text & "'"


I am getting the following error here

Conversion failed when converting date and/or time from character string.

Please tell me what to do..

Thanks
Posted
Comments
TrushnaK 14-Nov-13 0:37am    
are you trying to assigning the resulted value to be convert in date time.
[no name] 14-Nov-13 0:49am    
No..i am using a datepicker and i want to insert the value same as we select and in sql my datatype is date.
e.g. 14-11-2013
while inserting the value it's not giving any problem, but while updating it's giving the error..

SQL
Update OrderMaster set OrderFrmType='G',OrderDate='" & dtpOrderDate.SelectedDate.ToString("dd/MMM/yyyy") & "',SMGIDRef='" & j & "',MDIDRef='" & k & "', Remark='" & txtRemark.Text & "', AIDAgencyRef='" & l & "' where OrderFormNo='" & cmbOrderNo.Text & "'"

--Please try it if it is not multilingual. 

--If multilingual then 

Update OrderMaster set OrderFrmType='G',OrderDate='" & dtpOrderDate.SelectedDate.ToString("MM-dd-yyyy") & "',SMGIDRef='" & j & "',MDIDRef='" & k & "', Remark='" & txtRemark.Text & "', AIDAgencyRef='" & l & "' where OrderFormNo='" & cmbOrderNo.Text & "'"


--Change your insert query.

For more please visit me
 
Share this answer
 
v2
Thanks all for your help..
i got this in below way

VB
Dim strDate As DateTime
             strDate = DateTime.Parse(dtpOrderDate.Text, System.Globalization.CultureInfo.CreateSpecificCulture("en-GB").DateTimeFormat)
             Dim formatInfo As New System.Globalization.DateTimeFormatInfo()
             formatInfo.LongDatePattern = "MM/dd/yyyy"
             Dim strStartDate As String = strDate.ToString("MM/dd/yyyy", formatInfo)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900