Get specific rows from dataTable using the SELECT method.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I try to get specific rows from dataTable using the
select method with simple criteria.
For the following lines I the values of the variables are :
expression : "Account like 6133101" ("Account " is the name of my
column.)

Code:
System.Data.DataRow[] foundRows;
string expression;
expression = "Account like " + Convert.ToString(myRow["Account"]);
foundRows = myDS.Tables[i].Select(expression);

This code gives Error message :
{"Cannot perform 'Like' operation on System.String and System.Int32." }

Can U please help me and tell me what I do wrong?
Thank U in anticipation !!!
 
Niron said:
I try to get specific rows from dataTable using the
select method with simple criteria.
For the following lines I the values of the variables are :
expression : "Account like 6133101" ("Account " is the name of my
column.)

Code:
System.Data.DataRow[] foundRows;
string expression;
expression = "Account like " + Convert.ToString(myRow["Account"]);
foundRows = myDS.Tables[i].Select(expression);

This code gives Error message :
{"Cannot perform 'Like' operation on System.String and System.Int32." }

Try to change expression to "Account like '%6133101%'" -- add single
quotes and wildcards.
 
Thank U !!!!!!!
It works

Sericinus hunter said:
Niron said:
I try to get specific rows from dataTable using the
select method with simple criteria.
For the following lines I the values of the variables are :
expression : "Account like 6133101" ("Account " is the name of my
column.)

Code:
System.Data.DataRow[] foundRows;
string expression;
expression = "Account like " + Convert.ToString(myRow["Account"]);
foundRows = myDS.Tables[i].Select(expression);

This code gives Error message :
{"Cannot perform 'Like' operation on System.String and System.Int32." }

Try to change expression to "Account like '%6133101%'" -- add single
quotes and wildcards.
 
When I write this it works:
expression = "Account like '%6133101%' "
But I want to use variable (The following line return Error):
expression = "Account like " + Convert.ToDouble(myRow["Account"].ToString());
What is the syntax to use variable?
Thanks again!

Sericinus hunter said:
Niron said:
I try to get specific rows from dataTable using the
select method with simple criteria.
For the following lines I the values of the variables are :
expression : "Account like 6133101" ("Account " is the name of my
column.)

Code:
System.Data.DataRow[] foundRows;
string expression;
expression = "Account like " + Convert.ToString(myRow["Account"]);
foundRows = myDS.Tables[i].Select(expression);

This code gives Error message :
{"Cannot perform 'Like' operation on System.String and System.Int32." }

Try to change expression to "Account like '%6133101%'" -- add single
quotes and wildcards.
 
Back
Top