Datatable.select correct syntax

  • Thread starter Thread starter sam
  • Start date Start date
S

sam

Why the folowing code generates ans error in the select expression ?:
DataRow[] drRows = dsRevues.Tables[0].Select("year >= '2000' && year <=
'2007'");//

What is the correct syntax ?

Sam
 
Hi,

What error are you getting?

What type is the column "year" ?

If it's an integer just remove the ' around 2000 & 2007
 
Hi Sam
It should read
DataRow[] drRows = dsRevues.Tables[0].Select("year >= '2000' AND year <=
'2007'");

This is a more like SQL query, The MSDN for the select method has all the
allowed syntax you may need.

henk
 
Year is a string. The problem was the &&. I have replace it with AND and it
works fine.
Thanks you for help.
sam

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

What error are you getting?

What type is the column "year" ?

If it's an integer just remove the ' around 2000 & 2007

sam said:
Why the folowing code generates ans error in the select expression ?:
DataRow[] drRows = dsRevues.Tables[0].Select("year >= '2000' && year <=
'2007'");//

What is the correct syntax ?

Sam
 
Hi,

sam said:
Year is a string. The problem was the &&. I have replace it with AND and
it works fine.
Thanks you for help.
sam

Why are you keeping a column that represent year as a string?
 
Ignacio Machin ( .NET/ C# MVP ) said:
Why are you keeping a column that represent year as a string?
you are wright, but it is as is in the database I use.

sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top