1
Answer

Selecting datarow from datatable using parameters

Ask a question
Dean

Dean

11y
1k
1

Hi all;

In a Windows form, I'm trying to select a value from a datatable like so:

DataRow[] row = Customers.Select("name = '" + this.tbName.Text + "'");


Problem is, the value in  tbName.Text can contain a string with an apostrophe, so naturally I need to escape it.  Is there any way of using a parameter in this statement to get around this problem? Something like  DataRow[] row = Customers.Select("name =  @Name"); where Name = this.tbName.Text  for example?


Answers (1)