Having trouble with a persistent error. My form allows the user to see a list of elements in a particular group. The input for group number is a combobox called groupbox and the output is a combobox called ElementResults. I am getting the error on the line: GroupSearch.ExecuteNonQuery()
Imports System.Data.OleDb
Public Class ElementsSearch
Public Shared connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\A\My Documents\Visual Studio 2010\Projects\A2\Element.accdb;Persist Security Info=False;"
Public Shared ElementsTable
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim Search As New OleDbConnection(connectionString)
Search.Open()
Dim SearchCriteria As String
SearchCriteria = Groupbox.Text
Dim query As String = "SELECT * From ElementsTable WHERE Group='" & SearchCriteria & "'"
Dim GroupSearch As New OleDbCommand(query, Search)
GroupSearch.ExecuteNonQuery()
Dim reader As OleDbDataReader = GroupSearch.ExecuteReader()
ElementResults.Text = Convert.ToString(reader("Name"))
End Sub
End Class
SearchCriteria?GroupSearch.ExecuteNonQuery().Patrick Hofman'sanswer as this solved you're initial question.