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. 5 1578
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.
"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.
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.
"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. > >
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. > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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)...
|
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...
|
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
|
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...
|
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...
| |
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...
|
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 ...
|
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
|
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.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |