Partial Class _Default Inherits System.Web.UI.Page Dim Conn As String = "Data Source=220.226.186.188;Initial Catalog=TimeTable;Persist Security Info=True;User ID=jothi;Password=jothi" Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Label1.Visible = False End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sSql As String = "Insert Into personalcouncilform(Names,ContactNo,Email,City,datofreg,source) values('" & txtName.Text & "','" & txtMob.Text & "','" & txtMail.Text & "','" & DropDownList1.Text & "','" & Format(Now(), "yyyy-MM-dd HH:mm:ss") & "','IITJEE-2012')" Dim myCONN As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection myCONN.ConnectionString = Conn Dim insertCmd As New Data.SqlClient.SqlCommand(sSql, myCONN) Dim bSuccess As Boolean bSuccess = True Try myCONN.Open() insertCmd.ExecuteNonQuery() myCONN.Close() 'Response.Write("Successfully Inserted.") Label1.Visible = True Label1.Text = "Successfully Inserted. Thank You." Call Clear() Catch ex As Exception bSuccess = False Label1.Visible = True Label1.Text = "Failed:" & ex.Message 'Response.Write("Failed:" & ex.Message) Finally If myCONN.State = Data.ConnectionState.Open Then myCONN.Close() End If End Try End Sub Protected Sub Clear() txtName.Text = "" txtMob.Text = "" txtMail.Text = "" End Sub Protected Sub ClearLabel() txtName.Text = "" txtMob.Text = "" txtMail.Text = "" Label1.Visible = False End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click 'Button2.Attributes.Add("onClick", "document.forms[0].reset();return false;") ViewState.Clear() Response.Redirect(Request.Url.AbsoluteUri.ToString()) End Sub End Class