0

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

Edited by William Ng

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by IIM
0

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.

Edited by IIM

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.