Hello friends plz help again
How to coding in save button and how to convert the database in SQL Server 2005 in DropDown List becoz in sql take date in mm\dd\yy and in asp.net i m create the form dd\mm\yy? plz help me...

You must first get the value in the database then set that value.
For example:

'getValue is a function that will get a scalar value from you database.
Dim pDate as Date = getValue("Select getDate() as date",commandtype.text)

'if you want to display it in a label with your desired format
label1.text = format(pDate,"dd\mm\yy")

As far i understood you are asking for the code to save values from form to sql server 2005, and you have the date in dd/mm/yy format.
So you need to format date into sql date format while writing code for saving.
and you need to format date while retrieving also.
For example you have taken calender and two text box to save data into database.

so this will be the code :


boolean save()

Dim IsSaved As Boolean = False
Dim ConStr As String = "server=(server name);database=(your database name); user id=user id; password=password "
Dim Con As New System.Data.SqlClient.SqlConnection(ConStr)
Dim str As String = "insert into (table name) values('" & txtName.Text & " ','" & txtPhoneNo.Text & "','" & Format(Calendar1.SelectedDate, "dd\mm\yy") & "',')"
Dim cmd As New System.Data.SqlClient.SqlCommand(str, Con)
Try
Con.Open()
cmd.ExecuteNonQuery()
IsSaved = True
Catch ex As Exception

MsgBox(ex.Message)

Finally
Con.Close()
End Try
end sub

select CONVERT(VARCHAR, date1, 101) AS Date
date1 ........variable for date used in database

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.