Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I given format like this txtdate.text =format(now,"ddl1-Mm-yyyy")
Posted
Comments
ArunRajendra 17-Jun-14 7:39am    
How are converting in SQL
Thava Rajan 17-Jun-14 8:21am    
format(now,"ddl1-Mm-yyyy")
what kind of format is this or is it missspelled?
vanarajranjit 17-Jun-14 23:22pm    
L1missplaced actual dd mm yyyy
Nandakishore G N 18-Jun-14 4:33am    
Check in your sp whether the parameter datatype is Varchar or DateTime. if it is varchar change it to column datatype (datetime or date). But, before that paste what you have done.

i Think this will be enough for as a solution to your problem
txtdate.text =format(now,"dd-MMM-yyyy")

as per your previous solution comment
your actual problem is you need to Send it as a varchar
you need to pass it as a datetime,
Command.parameters. Add("@date",SqlDbType.Datetime).Value=Convert.ToDateTime(txtname.Text)

if you have still problem To debug this code put a break point on the line you mention and see what value is set it in to the parameter
 
Share this answer
 
v2
Don't convert the date to a string when creating your SQL - pass it in a parameterised query and pass the date in.

e.g. (snippet)
VB
Dim sql As String = "SELECT [filename] FROM [table] WHERE [filedate] = @FileDate"

Dim cmd As New SqlCommand(conn, sql)

cmd.Parameters.AddWithValue("@FileDate", Date.Now)
 
Share this answer
 
Comments
vanarajranjit 17-Jun-14 23:38pm    
I used like that
Command.parameters. Add("@date",SqlDbType.VarChar.varchar).Value=txtname.Text.
Duncan Edwards Jones 7-Jul-14 4:50am    
But a date is not a varchar - if you have a date and the parameter type on the table/database is a date don't convert it back and forth through a string.

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