i'm working on asp, vs2005. I should save the typed information in sql server. I connected and written the code in the following way
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ConnStr As String
Dim visitors_name, officer_to_visit, purpose, date_of_visit, time_in As String
Dim serial_no, year, floor As Integer
ConnStr = ConfigurationManager.ConnectionStrings("gate").ConnectionString()
Dim conn As New SqlConnection(ConnStr)
conn.Open()
serial_no = serialno.Text
year = years.Text
visitors_name = visitorsname.Text
officer_to_visit = officertovisit.Text
purpose = pur.Text
date_of_visit = dateofvisit.Text
floor = wing.Text
time_in = timein.Text
Dim adapter As New SqlClient.SqlDataAdapter("select serial_no,year,visitors_name,officer_to_visit,purpose,date_of_visit,floor,time_in,time_out from visitors_pass", conn)
Dim insert As New SqlClient.SqlCommand("insert into visitors_pass (serial_no,year,visitors_name,officer_to_visit,purpose,date_of_visit,floor,time_in,time_out) Values('" & serial_no & "' ,'" & year & "', '" & visitors_name & "','" & officer_to_visit & "','" & purpose & "','" & floor & "','" & date_of_visit & "','" & time_in & "')", conn)
insert.ExecuteNonQuery()
conn.Close()
WriteLine("record saved")
End Sub
but when i run it is showing an exceptional like
System.FormatException: Input string was not in a correct format.
and pointing towards
serial_no = serialno.Text
anyone plz can you tell where the error occured in the code and rectify it. I need it very urgently