473,385 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to check datatable.select

Hi,

How do I check datatable.select(filter) in the following:

for each dtrow in datatable.select(filter)
....
next

I've also tried:

if not (datatable.select(filter) is nothing) then
for each dtrow in datable.select(filter)
.....
next
end if
but it gets an exception in my catch.

I get an error when the select doesnt find any rows to return. How can I
chech for this or is there a property to use?
Basically, if the select doesnt find any rows, then I want to do something
else.

thanks,
Will
Jan 18 '06 #1
7 14970
"wk6pack" <wk***@sd61.bc.ca> schrieb
Hi,

How do I check datatable.select(filter) in the following:

for each dtrow in datatable.select(filter)
...
next

I've also tried:

if not (datatable.select(filter) is nothing) then
for each dtrow in datable.select(filter)
.....
next
end if
but it gets an exception in my catch.

I get an error when the select doesnt find any rows to return. How
can I chech for this or is there a property to use?
Basically, if the select doesnt find any rows, then I want to do
something else.

Check the length property of the array returned. If it's 0, no rows have
been returned.
Armin

Jan 18 '06 #2
WK6Pack,

Are you sure that your table exist?
\\\
Dim dt As DataTable
If Not dt Is Nothing Then
If Not dt.Select() Is Nothing Then
For Each dr As DataRow In dt.Select()
Next
End If
End If
///
This runs for me although that it does nothing of course.

I hope this helps,

Cor
Jan 18 '06 #3
Hi,

The table exists with records there. If you select on the filter without
finding a record in the datatable, it will error out.

thanks,
Will

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:OF**************@TK2MSFTNGP14.phx.gbl...
WK6Pack,

Are you sure that your table exist?
\\\
Dim dt As DataTable
If Not dt Is Nothing Then
If Not dt.Select() Is Nothing Then
For Each dr As DataRow In dt.Select()
Next
End If
End If
///
This runs for me although that it does nothing of course.

I hope this helps,

Cor

Jan 18 '06 #4
Hi,

There are records in the datatable but not on the filter. Datatable.rows.
ie. datatable has records a1, a2 but I want to see if a3 is in there.

datatable.select("col1='ad3') will error out with Error: can't find column
[a3]. I want to prevent this.

I'm not sure what you mean check the array length? I dont see that method
on the datatable.

thanks,
Will

"Armin Zingler" <az*******@freenet.de> wrote in message
news:OW**************@TK2MSFTNGP11.phx.gbl...
"wk6pack" <wk***@sd61.bc.ca> schrieb
Hi,

How do I check datatable.select(filter) in the following:

for each dtrow in datatable.select(filter)
...
next

I've also tried:

if not (datatable.select(filter) is nothing) then
for each dtrow in datable.select(filter)
.....
next
end if
but it gets an exception in my catch.

I get an error when the select doesnt find any rows to return. How
can I chech for this or is there a property to use?
Basically, if the select doesnt find any rows, then I want to do
something else.

Check the length property of the array returned. If it's 0, no rows have
been returned.
Armin

Jan 18 '06 #5
"wk6pack" <wk***@sd61.bc.ca> schrieb
Hi,

There are records in the datatable but not on the filter.
Datatable.rows. ie. datatable has records a1, a2 but I want to see
if a3 is in there.

datatable.select("col1='ad3') will error out with Error: can't find
column [a3]. I want to prevent this.
In this example, you use the column name "Col1", thus I don't understand how
it can not find column "a3". What are the available column names, what are
the values in these columns and what is the value you are searching for?
I'm not sure what you mean check the array length? I dont see that
method on the datatable.


I wrote, "of the array returned". I meant the array that is returned from
the Select method.
Armin

Jan 18 '06 #6
Hi Armin,

The column, col1 exists but the value in col1 is not found. so it returns
the error.

Will
"Armin Zingler" <az*******@freenet.de> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
"wk6pack" <wk***@sd61.bc.ca> schrieb
Hi,

There are records in the datatable but not on the filter.
Datatable.rows. ie. datatable has records a1, a2 but I want to see
if a3 is in there.

datatable.select("col1='ad3') will error out with Error: can't find
column [a3]. I want to prevent this.
In this example, you use the column name "Col1", thus I don't understand

how it can not find column "a3". What are the available column names, what are
the values in these columns and what is the value you are searching for?
I'm not sure what you mean check the array length? I dont see that
method on the datatable.


I wrote, "of the array returned". I meant the array that is returned from
the Select method.
Armin

Jan 18 '06 #7
"wk6pack" <wk***@sd61.bc.ca> schrieb
Hi Armin,

The column, col1 exists but the value in col1 is not found. so it
returns the error.


If it doesn't find a row, it does not return this error. If it does, there
must be something wrong elsewhere to which I don't have insight.

Can you reproduce the problem in a new project? If you can, you can send it
to me (zipped please; insert an underscore between "no" and "spam" in my
email address)
Armin

Jan 18 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Luc | last post by:
I am using Visual Studio 2003 and am getting lousy performance after using a datatable select and then trying to assign a value to a column of the row that was found: DataTable dt = new...
9
by: Frank | last post by:
Hi, I use datatable.select to select row in a table in a dataset. I use an ampersand in the selectstring and get an error that it is unsupported. The statement works fine in the query analyzer of...
4
by: Kris Rudin | last post by:
I am displaying a table of information on a web page, using an asp:table that I populate dynamically. On this page I give the user the options to group the rows by certain fields, and/or filter the...
2
by: Marcel Hug | last post by:
Hi NG! With a Inner-Join SQL I get my datas in a DataSet. In the table are the column Entry and Version. Like this: Entry Version 1 1 1 2 1 ...
4
by: Aryan | last post by:
Hi, I am having problem with DataTable.Select() method. I am using ASP.NET 2.0. I have DataSet which reads data from XML file using DataSet.ReadXML(). Now this dataset has various datatable,...
1
by: Maxwell2006 | last post by:
Hi, I am working with strongly typed datatables. What is the most efficient way to build a new DataTAble based on the result of DataTable.Select? At this point I use a foreach loop to do the...
5
by: Manikandan | last post by:
Hi, I have a datatable with rows. When I used datatable.select with values it is working properly, But when I use the select with variables it is not working. I tried with putting '(single...
3
by: Jeff | last post by:
hey ..NET 2.0 I have a datatable which consist of 3 columns (int, date, value). This DataTable have 3 rows, the values of the "date" ("date" column is of datetime datatype) column is:...
3
by: Nuno Magalhaes | last post by:
Hello, I have a DataTable in which the items are of type MyClass. How can I use Select to compare a MyClass instance with the DataTable? Is there any overriden method (like the ToString()) to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.