what is causing this error here "Operator '&' is not defined for string "select * from Miscellaneouse whe" and type 'DataRowView'."

 provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="
        dataFile = "C:\Users\PrintServer\Documents\Visual Studio 2010\Projects\Hr and Payroll1\HR and Payroll.accdb" ' Change it to your Access Database location
        connString = provider & dataFile
        myConnection.ConnectionString = connString
        myConnection.Open()

        Dim str As String
        str = "select * from Miscellaneouse where  Position = '" & SlcComboBox1.SelectedValue & "' "
        Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
        dr = cmd.ExecuteReader
        While dr.Read()
            SlcTextBox9.Text = dr("Salary").ToString

        End While
        myConnection.Close()

Try

str = "select * from Miscellaneouse where  Position = '" & SlcComboBox1.SelectedItem & "' "

Try this

str = "select * from Miscellaneouse where Position = " & "'" & SlcComboBox1.SelectedValue & "'"

SelectedValue gets or sets the value of the member property specified by the ListControl.ValueMember property. SelectedItem returns the text of the selected item. If you look at the value of SelectedValue in the selection changed event you will get the value Null which would not work in the query.

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.