0

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()
3
Contributors
3
Replies
18
Views
3 Weeks
Discussion Span
Last Post by Reverend Jim
-1

Try this

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

0

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.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.