3
Answers

How to use query parameters to access a datatable?

Dean

Dean

12y
1.6k
1
I have a datatable called "PostCodes", and I'm trying to retrieve a row that matches a name for the suburb that is currently displayed in a combo box. The code is very simple:

DataRow[] result = PostCodes.Select("Locality = '" + cbSuburb.Text + "'");
foreach (DataRow row in result)
        {
                tbPostCode.Text = row[0].ToString();
                tbState.Text = row[2].ToString();
        }

However even though this works quite well, I want to use query parameters to get around the age-old problem of quotation marks in the Locality field. 

Is there a simple way to do this? I can't seem to find anything relating to using query parameters on a datatable.
 
Answers (3)