Guy

Guy

  • NA
  • 3
  • 10.3k

Cant get DataAdapter parameter to take C# string variable

Oct 5 2010 5:18 PM

Im trying to add a search box onto my winform. Im using SqlCE.
Im trying to get the sqlceDataAdapter to take a string variable, but when I press the button to search it tells my that the stored procedure is not valid, WHEN IT IS. Here is the code:
 
private void button1_Click(object sender, EventArgs e)
{
 string search = "\"SELECT * FROM people\"";
 con = new SqlCeConnection("Data Source = DBtest.sdf;Persist Security Info=False");
con.Open();
MessageBox.Show(con.State.ToString());
 SqlCeDataAdapter a = new SqlCeDataAdapter(search, con);
DataTable t = new DataTable(); a.Fill(t); dataGridView1.DataSource = t;
}
 }
Ideally I wanted to add a textbox where the user can type in a last name and it will search my database and display it.. My db is a SDF file..
Any help will be appreciated.

Answers (2)