Showing posts with label textbox. Show all posts
Showing posts with label textbox. Show all posts

Monday, February 20, 2012

Problem inserting date

Hello

The date format in SQL Server 2000 is dd-MM-yyyy. I am writing the following code in the buttons click event. I am using a textbox and button.

Dim conn as SqlConnection=new SqlConnection(connection string)

Dim ins as string="insert into Sample(dval) values(' " & TextBox1.Text & " ')"

Dim cmd as SQlCommand=new SqlCommand(sel,conn)

conn.open()

cmd.ExecuteNonQuerry()

conn.close()

When i am inserting the date 05-03-2007 in the textbox and clicking the button it is inserting date

03-05-2007 rather than 05-03-2007. What changes should i make in the code?

Rathish

Hi,

before insert, convert the date to yyyymmdd, with this no matter the config of your SQL

|||Hello How to convert date to yyyy-mm-dd.Rathish