m a newbie to aspx vb.net and need some help...i've got a login form with staff id adn date of birth loging in credentials. m using 3 drop down lists to capture day,month and year(m populating the day month and year in the page load event). below is my login code...in which i am getting an error as below
---------------------------------------------------------------------------------------
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

Line 48: Dim datetime As Date
Line 49: Dim test_value As Integer
Line 50: test_value = DropDay.SelectedValue
Line 51:
Line 52: datetime = DropDay.SelectedValue & "/" & DropMonth.SelectedValue & "/" & DropYear.SelectedValue
---------------------------------------------------------------------------------------

this is the login code

Dim StrConnString, sql
        'Dim conn As SqlConnection
        'Dim myCommand As SqlCommand
        Dim Comm As SqlCommand
        Dim dr As SqlDataReader
        Dim datetime As Date
        Dim test_value As Integer
        test_value = DropDay.SelectedValue

        datetime = DropDay.SelectedValue & "/" & DropMonth.SelectedValue & "/" & DropYear.SelectedValue

        StrConnString = ConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString
        Dim conn = New SqlConnection(StrConnString)
        conn.Open()

        Comm = New Data.SqlClient.SqlCommand("select * from members where Certificate=@Certificate and DateofBirth=@DateofBirth", conn)
        Comm.Parameters.Add("@Certificate", Data.SqlDbType.NVarChar).Value = txt_certno.Text
        Comm.Parameters.Add("@DateofBirth", Data.SqlDbType.DateTime).Value = datetime

        Comm = New SqlCommand(SQL, conn)
        dr = Comm.ExecuteReader()

        If dr.Read() Then
            Session("Class") = dr("mc_color").ToString()
            Session("CertID") = dr("cert_no").ToString()
            Session("DOB") = dr("dob").ToString()
            Response.Redirect("~/pages/Myaccount.aspx")
        Else
            lblerror.Text = "Incorrect Certification number or Date of Birth! Please try again"
        End If
        dr.Close()
        conn.Close()

I prefer that you must assign your datetime variable datatypes to String because datatype date will give you an output date and time values that's why you are getting those error.

Try this:

Dim datetime as string
datetime = DropDay.SelectedValue & "/" & DropMonth.SelectedValue & "/" & DropYear.SelectedValue
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.