I try to convert programType from string to integer value
but it show me "Input string was not in a correct format." error..can anyone help to to solve this question?

Private Sub cmbProgram_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbProgram.SelectionChangeCommitted
        'converting string to integer value'
        Dim programType As Integer = Integer.Parse(cmbProgram.SelectedValue.ToString)
        Dim sqlselect As String = "select ProgramCode from Program where ProgramType =" & programType
        Dim dr As OleDbDataReader

        conn.Open()
        cmd = New OleDbCommand(sqlselect, conn)
        dr = cmd.ExecuteReader
        dr.Read()

        Dim programCode As String = dr("ProgramCode")
        txtProgramCode.Text = programCode
        dr.Close()
        conn.Close()
    End Sub

cmbProgram.SelectedValue.ToString

is the return type of above method contains numeric values?if yes then syntax is correct,otherwise you have to check for the condition that if it is numeric then call Integer.parse() else return error.

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.