I've created a program to write form data to an access database. Currently I am extending it so that I can read the data back from the database.
I have created a new dialog with a datagridview to view the table data. I wish to be able to search for a specific User ID, the User ID can have multiple instances within the database. So I want the search to display all of the rows for that ID.
I thought I had it sorted but am getting:
syntax error (missing operator)
In the line:
Here is the code I have for the search button:
string ConString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Database.mdb"; OleDbConnection Con = new OleDbConnection(ConString); OleDbCommand Command = Con.CreateCommand(); // create the DataSet DataSet ds = new DataSet(); // clear the grids data source dtaSearchID.DataSource = null; // open the connection Con.Open(); // run the query Command.CommandText = "Select * From Codes Where User ID = " + txtSearchID.Text; OleDbDataAdapter Adapter = new OleDbDataAdapter(Command); Adapter.Fill(ds); // close the connection Con.Close(); // set the grid's data source dtaSearchID.DataSource = ds.Tables;
In the end I would like to be able to load the selected row data back into my main dialog. But I will deal with that when I get to it.
Any help would be greatly appreciated.