473,849 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datatable indexing problem

I am having a problem with a Datatable access.

This statement apparently works fine:

response.write( GetRows.Rows(kt r)(1))

and this statement does not:

if e.day.date = GetRows(ktr)(1) then

Here is the snippet of code that has these statements
*************** *************** *************** *************** **********
Dim GetRows as DataTable = sqlDS.tables("e ventCalendar")
Dim totalRows as integer
Dim totalColumns as Integer

totalRows = GetRows.Rows.Co unt
totalColumns = GetRows.Columns .count
response.write( "Rows read again = " & totalRows & " columns = " &
totalColumns & "<br>")

for ktr = 0 to GetRows.Rows.Co unt - 1
response.write( GetRows.Rows(kt r)(1))
response.write( e.day.date)
if CDate(e.day.dat e) = _
CDate(GetRows(k tr)(1)) then
*************** *************** *************** *************** *************** *
*******

Here is the error I get.
*************** *************** *************** *************** *************** *
************
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30367: Class 'System.Data.Da taTable' cannot be
indexed because it has no default property.

Source Error:

Line 124: response.write( e.day.date)
Line 125: if CDate(e.day.dat e) = _
Line 126: CDate(GetRows(k tr)(1)) then
Line 127: response.write( "Dates equal")
Line 128: else
*************** *************** *************** *************** *************** *
*

Why cannot the GetRows Datatable not be indexed in the if statement, but it
works fine in the response.write?

Thanks,

Tom.
Nov 18 '05 #1
5 1581
Rows collection has no indexes by name - only by index
so if you want to get the value from the first row whitin the ktr column you
have to write

GetRows.Rows(1) (ktr)
Regards
Martin

"Thomas Scheiderich" <tf*@deltanet.c om> wrote in message
news:10******** *****@corp.supe rnews.com...
I am having a problem with a Datatable access.

This statement apparently works fine:

response.write( GetRows.Rows(kt r)(1))

and this statement does not:

if e.day.date = GetRows(ktr)(1) then

Here is the snippet of code that has these statements
*************** *************** *************** *************** **********
Dim GetRows as DataTable = sqlDS.tables("e ventCalendar")
Dim totalRows as integer
Dim totalColumns as Integer

totalRows = GetRows.Rows.Co unt
totalColumns = GetRows.Columns .count
response.write( "Rows read again = " & totalRows & " columns = " &
totalColumns & "<br>")

for ktr = 0 to GetRows.Rows.Co unt - 1
response.write( GetRows.Rows(kt r)(1))
response.write( e.day.date)
if CDate(e.day.dat e) = _
CDate(GetRows(k tr)(1)) then
*************** *************** *************** *************** *************** * *******

Here is the error I get.
*************** *************** *************** *************** *************** * ************
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30367: Class 'System.Data.Da taTable' cannot be
indexed because it has no default property.

Source Error:

Line 124: response.write( e.day.date)
Line 125: if CDate(e.day.dat e) = _
Line 126: CDate(GetRows(k tr)(1)) then
Line 127: response.write( "Dates equal")
Line 128: else
*************** *************** *************** *************** *************** * *

Why cannot the GetRows Datatable not be indexed in the if statement, but it works fine in the response.write?

Thanks,

Tom.

Nov 18 '05 #2
"Martin Marinov" <me********@mec rossroad.bg> wrote in message
news:OX******** ******@TK2MSFTN GP11.phx.gbl...
Rows collection has no indexes by name - only by index
so if you want to get the value from the first row whitin the ktr column you have to write

GetRows.Rows(1) (ktr)
Actually, it is the other way around. The row is the number that is
changing. Column 1 is a date I was trying to get out of the table which
happens to be in the 2nd column (starting at 0).

ktr is going to be equal to 0 and 1 (as there are 2 rows in the table at the
moment). Totalrows is = 2.

What I am confused is why the response.write line works and the if test does
not.

Tom.

Regards
Martin

"Thomas Scheiderich" <tf*@deltanet.c om> wrote in message
news:10******** *****@corp.supe rnews.com...
I am having a problem with a Datatable access.

This statement apparently works fine:

response.write( GetRows.Rows(kt r)(1))

and this statement does not:

if e.day.date = GetRows(ktr)(1) then

Here is the snippet of code that has these statements
*************** *************** *************** *************** **********
Dim GetRows as DataTable = sqlDS.tables("e ventCalendar")
Dim totalRows as integer
Dim totalColumns as Integer

totalRows = GetRows.Rows.Co unt
totalColumns = GetRows.Columns .count
response.write( "Rows read again = " & totalRows & " columns = " &
totalColumns & "<br>")

for ktr = 0 to GetRows.Rows.Co unt - 1
response.write( GetRows.Rows(kt r)(1))
response.write( e.day.date)
if CDate(e.day.dat e) = _
CDate(GetRows(k tr)(1)) then

*************** *************** *************** *************** *************** *
*******

Here is the error I get.

*************** *************** *************** *************** *************** *
************
Compilation Error
Description: An error occurred during the compilation of a resource

required
to service this request. Please review the following specific error

details
and modify your source code appropriately.

Compiler Error Message: BC30367: Class 'System.Data.Da taTable' cannot be
indexed because it has no default property.

Source Error:

Line 124: response.write( e.day.date)
Line 125: if CDate(e.day.dat e) = _
Line 126: CDate(GetRows(k tr)(1)) then
Line 127: response.write( "Dates equal")
Line 128: else

*************** *************** *************** *************** *************** *
*

Why cannot the GetRows Datatable not be indexed in the if statement, but

it
works fine in the response.write?

Thanks,

Tom.


Nov 18 '05 #3
It is may be because DataTable.Rows( RowIndex)(Colum nIndex) return object and
you have to convert it to datatime object like

if Not GetRows(ktr)(1) = Nothing Then
if e.day.date = DateTime.Parse( GetRows(ktr)(1) .ToString()) then

Hope This Helps
Regards
Martin

"Thomas Scheiderich" <tf*@deltanet.c om> wrote in message
news:10******** *****@corp.supe rnews.com...
"Martin Marinov" <me********@mec rossroad.bg> wrote in message
news:OX******** ******@TK2MSFTN GP11.phx.gbl...
Rows collection has no indexes by name - only by index
so if you want to get the value from the first row whitin the ktr column you
have to write

GetRows.Rows(1) (ktr)


Actually, it is the other way around. The row is the number that is
changing. Column 1 is a date I was trying to get out of the table which
happens to be in the 2nd column (starting at 0).

ktr is going to be equal to 0 and 1 (as there are 2 rows in the table at

the moment). Totalrows is = 2.

What I am confused is why the response.write line works and the if test does not.

Tom.


Regards
Martin

"Thomas Scheiderich" <tf*@deltanet.c om> wrote in message
news:10******** *****@corp.supe rnews.com...
I am having a problem with a Datatable access.

This statement apparently works fine:

response.write( GetRows.Rows(kt r)(1))

and this statement does not:

if e.day.date = GetRows(ktr)(1) then

Here is the snippet of code that has these statements
*************** *************** *************** *************** **********
Dim GetRows as DataTable = sqlDS.tables("e ventCalendar")
Dim totalRows as integer
Dim totalColumns as Integer

totalRows = GetRows.Rows.Co unt
totalColumns = GetRows.Columns .count
response.write( "Rows read again = " & totalRows & " columns = " &
totalColumns & "<br>")

for ktr = 0 to GetRows.Rows.Co unt - 1
response.write( GetRows.Rows(kt r)(1))
response.write( e.day.date)
if CDate(e.day.dat e) = _
CDate(GetRows(k tr)(1)) then

*************** *************** *************** *************** *************** *
*******

Here is the error I get.

*************** *************** *************** *************** *************** *
************
Compilation Error
Description: An error occurred during the compilation of a resource

required
to service this request. Please review the following specific error

details
and modify your source code appropriately.

Compiler Error Message: BC30367: Class 'System.Data.Da taTable' cannot be indexed because it has no default property.

Source Error:

Line 124: response.write( e.day.date)
Line 125: if CDate(e.day.dat e) = _
Line 126: CDate(GetRows(k tr)(1)) then
Line 127: response.write( "Dates equal")
Line 128: else

*************** *************** *************** *************** *************** *
*

Why cannot the GetRows Datatable not be indexed in the if statement,
but it
works fine in the response.write?

Thanks,

Tom.



Nov 18 '05 #4
"Martin Marinov" <me********@mec rossroad.bg> wrote in message
news:eS******** ******@TK2MSFTN GP09.phx.gbl...
It is may be because DataTable.Rows( RowIndex)(Colum nIndex) return object and you have to convert it to datatime object like

if Not GetRows(ktr)(1) = Nothing Then
if e.day.date = DateTime.Parse( GetRows(ktr)(1) .ToString()) then
Tried it. Still doesn't work.

Here is the result and the new code:

*************** *************** *************** *************** *************
Compiler Error Message: BC30367: Class 'System.Data.Da taTable' cannot be
indexed because it has no default property.

Source Error:

Line 124: response.write( e.day.date)
Line 125: if e.day.date = _
Line 126: DateTime.Parse( GetRows(ktr)(1) .ToString) then
Line 127: response.write( "Dates equal")
Line 128: else
Source File: c:\inetpub\wwwr oot\contour\Com pany Info\TMP1lpu3zq 39q.aspx
Line: 126
*************** *************** *************** *************** *************** *
****
for ktr = 0 to GetRows.Rows.Co unt - 1
response.write( GetRows.Rows(kt r)(1))
response.write( e.day.date)
if e.day.date = _
DateTime.Parse( GetRows(ktr)(1) .ToString) then
response.write( "Dates equal")
else
response.write( "dates not equal")
end if
next
*************** *************** *************** *************** *************** *
*

It is interesting that the response.write works but the compare does not.

Tom
Hope This Helps
Regards
Martin

"Thomas Scheiderich" <tf*@deltanet.c om> wrote in message
news:10******** *****@corp.supe rnews.com...
"Martin Marinov" <me********@mec rossroad.bg> wrote in message
news:OX******** ******@TK2MSFTN GP11.phx.gbl...
Rows collection has no indexes by name - only by index
so if you want to get the value from the first row whitin the ktr column
you
have to write

GetRows.Rows(1) (ktr)
Actually, it is the other way around. The row is the number that is
changing. Column 1 is a date I was trying to get out of the table which
happens to be in the 2nd column (starting at 0).

ktr is going to be equal to 0 and 1 (as there are 2 rows in the table at

the
moment). Totalrows is = 2.

What I am confused is why the response.write line works and the if test

does
not.

Tom.


Regards
Martin

"Thomas Scheiderich" <tf*@deltanet.c om> wrote in message
news:10******** *****@corp.supe rnews.com...
> I am having a problem with a Datatable access.
>
> This statement apparently works fine:
>
> response.write( GetRows.Rows(kt r)(1))
>
> and this statement does not:
>
> if e.day.date = GetRows(ktr)(1) then
>
> Here is the snippet of code that has these statements
>
*************** *************** *************** *************** ********** > Dim GetRows as DataTable = sqlDS.tables("e ventCalendar")
> Dim totalRows as integer
> Dim totalColumns as Integer
>
> totalRows = GetRows.Rows.Co unt
> totalColumns = GetRows.Columns .count
> response.write( "Rows read again = " & totalRows & " columns = " &
> totalColumns & "<br>")
>
> for ktr = 0 to GetRows.Rows.Co unt - 1
> response.write( GetRows.Rows(kt r)(1))
> response.write( e.day.date)
> if CDate(e.day.dat e) = _
> CDate(GetRows(k tr)(1)) then
>

*************** *************** *************** *************** *************** *
> *******
>
> Here is the error I get.
>

*************** *************** *************** *************** *************** *
> ************
> Compilation Error
> Description: An error occurred during the compilation of a resource
required
> to service this request. Please review the following specific error
details
> and modify your source code appropriately.
>
> Compiler Error Message: BC30367: Class 'System.Data.Da taTable' cannot be
> indexed because it has no default property.
>
> Source Error:
>
> Line 124: response.write( e.day.date)
> Line 125: if CDate(e.day.dat e) = _
> Line 126: CDate(GetRows(k tr)(1)) then
> Line 127: response.write( "Dates equal")
> Line 128: else
>

*************** *************** *************** *************** *************** * > *
>
> Why cannot the GetRows Datatable not be indexed in the if statement, but it
> works fine in the response.write?
>
> Thanks,
>
> Tom.
>
>



Nov 18 '05 #5
Hi Thomas,

Please excuse me but i was in hurry and missed something
this line
DateTime.Parse( GetRows(ktr)(1) .ToString) then
should be
DateTime.Parse( GetRows.Rows(kt r)(1).ToString) then

as you can see i've missed the Rows collection that need to be indexed

Regards
Martin
"Thomas Scheiderich" <tf*@deltanet.c om> wrote in message
news:10******** *****@corp.supe rnews.com...
"Martin Marinov" <me********@mec rossroad.bg> wrote in message
news:eS******** ******@TK2MSFTN GP09.phx.gbl...
It is may be because DataTable.Rows( RowIndex)(Colum nIndex) return object and
you have to convert it to datatime object like

if Not GetRows(ktr)(1) = Nothing Then
if e.day.date = DateTime.Parse( GetRows(ktr)(1) .ToString()) then


Tried it. Still doesn't work.

Here is the result and the new code:

*************** *************** *************** *************** *************
Compiler Error Message: BC30367: Class 'System.Data.Da taTable' cannot be
indexed because it has no default property.

Source Error:

Line 124: response.write( e.day.date)
Line 125: if e.day.date = _
Line 126: DateTime.Parse( GetRows(ktr)(1) .ToString) then
Line 127: response.write( "Dates equal")
Line 128: else
Source File: c:\inetpub\wwwr oot\contour\Com pany Info\TMP1lpu3zq 39q.aspx
Line: 126

*************** *************** *************** *************** *************** * ****
for ktr = 0 to GetRows.Rows.Co unt - 1
response.write( GetRows.Rows(kt r)(1))
response.write( e.day.date)
if e.day.date = _
DateTime.Parse( GetRows(ktr)(1) .ToString) then
response.write( "Dates equal")
else
response.write( "dates not equal")
end if
next
*************** *************** *************** *************** *************** * *

It is interesting that the response.write works but the compare does not.

Tom

Hope This Helps
Regards
Martin

"Thomas Scheiderich" <tf*@deltanet.c om> wrote in message
news:10******** *****@corp.supe rnews.com...
"Martin Marinov" <me********@mec rossroad.bg> wrote in message
news:OX******** ******@TK2MSFTN GP11.phx.gbl...
> Rows collection has no indexes by name - only by index
> so if you want to get the value from the first row whitin the ktr column you
> have to write
>
> GetRows.Rows(1) (ktr)

Actually, it is the other way around. The row is the number that is
changing. Column 1 is a date I was trying to get out of the table which happens to be in the 2nd column (starting at 0).

ktr is going to be equal to 0 and 1 (as there are 2 rows in the table at
the
moment). Totalrows is = 2.

What I am confused is why the response.write line works and the if
test
does
not.

Tom.
>
>
> Regards
> Martin
>
> "Thomas Scheiderich" <tf*@deltanet.c om> wrote in message
> news:10******** *****@corp.supe rnews.com...
> > I am having a problem with a Datatable access.
> >
> > This statement apparently works fine:
> >
> > response.write( GetRows.Rows(kt r)(1))
> >
> > and this statement does not:
> >
> > if e.day.date = GetRows(ktr)(1) then
> >
> > Here is the snippet of code that has these statements
> > *************** *************** *************** *************** ********** > > Dim GetRows as DataTable = sqlDS.tables("e ventCalendar")
> > Dim totalRows as integer
> > Dim totalColumns as Integer
> >
> > totalRows = GetRows.Rows.Co unt
> > totalColumns = GetRows.Columns .count
> > response.write( "Rows read again = " & totalRows & " columns = "
& > > totalColumns & "<br>")
> >
> > for ktr = 0 to GetRows.Rows.Co unt - 1
> > response.write( GetRows.Rows(kt r)(1))
> > response.write( e.day.date)
> > if CDate(e.day.dat e) = _
> > CDate(GetRows(k tr)(1)) then
> >
>

*************** *************** *************** *************** *************** *
> > *******
> >
> > Here is the error I get.
> >
>

*************** *************** *************** *************** *************** *
> > ************
> > Compilation Error
> > Description: An error occurred during the compilation of a resource > required
> > to service this request. Please review the following specific error > details
> > and modify your source code appropriately.
> >
> > Compiler Error Message: BC30367: Class 'System.Data.Da taTable' cannot
be
> > indexed because it has no default property.
> >
> > Source Error:
> >
> > Line 124: response.write( e.day.date)
> > Line 125: if CDate(e.day.dat e) = _
> > Line 126: CDate(GetRows(k tr)(1)) then
> > Line 127: response.write( "Dates equal")
> > Line 128: else
> >
>

*************** *************** *************** *************** *************** *
> > *
> >
> > Why cannot the GetRows Datatable not be indexed in the if

statement, but
> it
> > works fine in the response.write?
> >
> > Thanks,
> >
> > Tom.
> >
> >
>
>



Nov 18 '05 #6

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

Similar topics

6
2752
by: Michael Drumheller | last post by:
(If you're not interested in NumArray, please skip this message.) I am new to NumArray and I wonder if someone can help me with array-indexing. Here's the basic situation: Given a rank-2 array (i.e., a matrix) it seems to be trivial, with array indexing, to extract a subset of its *columns*. But it does not seem to be trivial to extract a subset of its *rows*. The code snippet below describes the problem (if it really is a problem)...
108
6498
by: Bryan Olson | last post by:
The Python slice type has one method 'indices', and reportedly: This method takes a single integer argument /length/ and computes information about the extended slice that the slice object would describe if applied to a sequence of length items. It returns a tuple of three integers; respectively these are the /start/ and /stop/ indices and the /step/ or stride length of the slice. Missing or out-of-bounds indices are handled in a manner...
3
5909
by: nandan | last post by:
Hi, Has any one ever compared the performance of calling a DataTable's Select method with a stored procedure doing the same thing? My point is: dataRows = DataTable.Select(filter) is better or Passing paramters to stored procedure? The datatable holds about 500-700 rows at any given time. If I select one of the approaches the business logic will go into respective layers.With dotnet in picture what would be a good approach
3
6347
by: Solel Software | last post by:
Hello, I have a basic question. I have a DataTable of information without a database store (it's only in memory). I am looking to somehow query the DataTable to find out which row(s) satisfy certain criteria and then update the data in those rows, all without any sort of database access (no DataAdapters or anything). The table does not have a primary key so I've been using DataTable.DefaultView.Find to get the index of the row that...
7
1822
by: Ryan | last post by:
I have a bit of a problem with regards an indexing strategy. Well, basically there is no indexing strategy on a set of data I have at work. Now, I didn't create the design as I would have allowed for this. OK, so there is primary key (clustered) indexes (mainly composite keys), but no other indexes on the tables. As you would expect, the performance leaves a lot to be desired. A hell of a lot. We have several million rows in a lot of the...
7
6615
by: Susan Mackay | last post by:
I have a data table that is connected to a database table with a data adapter in the 'standard' manner. However I want to be able to remove selected rows from the data table (i.e. no longer include them in the set that is displayed to the user) but I don't want to delete the corresponding row from the database. I've tried using the .Rows.Remove() method but an exception is thrown to say I don't have a 'delete' command in the data...
1
1831
by: macupryk | last post by:
I need to get the value of a datatable. _dtProjectQuestion, ProjectQuestionToDatabase.ProjectResponseandRespondentToDB(_dtProjectQuestion, intId, Convert.ToInt32(var.no)); Error 1 Cannot apply indexing with to an expression of type 'System.Data.DataTable' C:\Voxco.ReportGenerator\dotNET2.0\Voxco.ReportGenerator\Voxco.ReportGeneratorImport\Voxco.ReportGenerator.Importing\XMLParseProject.cs 90 76 ...
9
15613
by: Pascal Berger | last post by:
What's the fastest way to accomplish the following tasks: - Copy all data from one DataTable to another. Currently I work with CreateDataReader() / Load(). Is there any faster approach? - Add a lot of rows (>10'000) to a DataTable (one by one). Currently I use NewRow() / AddRow(). It's painfully slow. I know I can disable indexing during the import. Any other possible optimizations? Thanks in advance Pascal
6
1458
by: ArunDhaJ | last post by:
Hi All, I'm having a DataTable with say 3 columns. I've to copy this DataTable to another DataTable which has 4 columns. The extra column is the Row_ID with AutoIncrement property set true. Is this way is possible? Anyways, what I actually need is to add a new column Row_ID with AutoIncrement values.
0
11005
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10665
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9501
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7894
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5735
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5921
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4139
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.