T
Tom
Hi, I have some kind of problems with an apostrophe character ('). I would
like to select from DataTable DataRow containing value horses' (with an
apostrophe on the end). But when I do it in an obvious way, like this:
DataTable dt = new DataTable();
DataColumn id = new DataColumn("ID", Type.GetType("System.Int32"));
DataColumn str = new DataColumn("STR", Type.GetType("System.String"));
dt.Columns.Add(id);
dt.Columns.Add(str);
DataRow dr;
dr = dt.NewRow();
dr["STR"] = "horses'";
dt.Rows.Add(dr);
string ster = "STR = 'horses'";
DataRow[] wyn = dt.Select(ster);
I get an error shown below.
An unhandled exception of type 'System.Data.SyntaxErrorException' occurred
in system.data.dll
Additional information: The expression contains an invalid string constant:
'horses''.
I know its related with the apostrophe character, but cant "google" anything
to make this work properly. Could you help me please?
Best regars, Tom
like to select from DataTable DataRow containing value horses' (with an
apostrophe on the end). But when I do it in an obvious way, like this:
DataTable dt = new DataTable();
DataColumn id = new DataColumn("ID", Type.GetType("System.Int32"));
DataColumn str = new DataColumn("STR", Type.GetType("System.String"));
dt.Columns.Add(id);
dt.Columns.Add(str);
DataRow dr;
dr = dt.NewRow();
dr["STR"] = "horses'";
dt.Rows.Add(dr);
string ster = "STR = 'horses'";
DataRow[] wyn = dt.Select(ster);
I get an error shown below.
An unhandled exception of type 'System.Data.SyntaxErrorException' occurred
in system.data.dll
Additional information: The expression contains an invalid string constant:
'horses''.
I know its related with the apostrophe character, but cant "google" anything
to make this work properly. Could you help me please?
Best regars, Tom