Hi all,

I have a Subscription database running and i am trying to insert values into it from an ASP web form when i click on a button with an id of 'confirm'. The name of the field is 'startdate' (date data type) and i need to enter today's date into that record but everytime i do it comes with an error message:

"Exception Details: System.Data.SqlClient.SqlException: Conversion failed when converting date and/or time from character string."

The name of the table is 'Subscription' and I am using Visual Basic as my programming language.

Any help would be much appreciated.

Declare the type of Data field as Nchar(10),if U use sql server database.

try this code

Dim con as new sqlconnection
Dim com as new sqlcommand
con.ConnectionString="give connection string"
com.commandText="insert into tablename values(@joindate,@...)"

Hope this helps U
If it helps make it as solved

I believe your column datatype in the SQL Database in an "DateTime", correct? If so then use sudharani's code except change the SqlDbType over to a DateTime instead of nchar.

Thanks all. I just did the lazy way and changed my data type to nvarchar. This fixed it all up.