I'm drawing data from xml file, putting it into datarows, from
datatable subroutine (UseXMLDocument) , and I'm getting a
"System.IndexOutOfRangeException: There is no row at position 0" at the
" Data.Append(dtaData.Rows(0)("Name") & "<BR>") " line.
''''''''''''''
<%@ Page Language="VB" debug="true"%>
<SCRIPT LANGUAGE=VB RUNAT=SERVER>
Private dtaData As DataTable = New DataTable()
Private ID As String
Private Name As String
Private NewDataRow As DataRow
Private ItemsOnlineDataURL As String
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim PreviousCategory As String = Nothing
Dim Data As StringBuilder = New StringBuilder()
Dim SalesRepID As String = Request.QueryString("SID")
Dim PurchaseLink As String =
"http://www.shoppe.com/ItemsOnline/Purchase.aspx?"
Dim Spacer As String = "<IMG SRC=spacer.gif>"
ItemsOnlineDataURL =
"http://www.shoppe.com/ItemsOnline/Data/salesrep1.xml"
Try
dtaData.Columns.Add("ID")
dtaData.Columns.Add("Name")
dtaData.Columns.Add("PurchaseID")
dtaData.Columns.Add("PkgName")
dtaData.Columns.Add("SelectBlurb")
dtaData.Columns.Add("PkgAmount")
dtaData.Columns.Add("PkgPhone")
dtaData.Columns.Add("DailyItem")
dtaData.Columns.Add("Custom")
dtaData.Columns.Add("WeeklyAmount")
dtaData.Columns.Add("MonthlyAmount")
dtaData.Columns.Add("Category")
UseXmlDocument()
Data.Append(dtaData.Rows(0)("Name") & "<BR>")
Dim drwData As DataRow
For Each drwData In dtaData.Rows
Dim SID As String = "SID=" & Convert.ToString(drwData("ID")) & "&"
Dim PurchaseTypeID As String =
Convert.ToString(drwData("PurchaseID"))
Dim PkgAmount As String =
FormatAmount(Convert.ToSingle(drwData("PkgAmount") ))
Dim PkgPhone As String = Convert.ToString(drwData("PkgPhone"))
Dim PurchaseType As String =
(Convert.ToString(drwData("DailyItem")) )
''''''''''''
.....more coding can be provided if someone can in fact help decipher
why I'm getting the error.
TIA
netsports 4 967
Hi netsports,
Since dtaData is a newly created table, it has no rows yet. Therefore,
you cannot access dtaData.Rows(0), since it does not exist. To add rows
to a new table, use the NewRow() method of DataTable to create a row.
Then, set the values of the fields of that new row. Finally, call
dtaData.Rows.Add(yourNewRowObject).
Hope this helps.
-KJ
KJ, thanks for the reply -
I have declared dtaData , and I thought I have declared a new row in
the declarations below (and in my code above):
'''''''''''''''
Private dtaData As DataTable = New DataTable()
Private ID As String
Private Name As String
Private NewDataRow As DataRow
''''''''''''''''''
netsports
The code:
Data.Append(dtaData.Rows(0)("Name") & "<BR>")
fails because dtaData.Rows has no rows in it (dtaData.Rows(0) =
Nothing).
So, before this line, assign a value to NewDataRow using the NewRow()
method, for example:
'assign:
NewDataRow = dtaData.NewRow()
'then set a value:
NewDataRow("Name") = "foo"
'finally, assign the row to your table's Rows collection:
dtaData.Rows.Add(NewDataRow)
'then you can do (no error) because Rows(0) is no longer Nothing:
Data.Append(dtaData.Rows(0)("Name") & "<BR>")
Give this a try and tell me what happens.
Yeah, KJ, I think that does the trick (at least for now, as I have
encountered a different error downstream) .
I had to use the ConvertC# toVB.NET program since the initial code was
in C# , so it probably didnt do a true 100% conversion.
Thanks again
netsports This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: AIM |
last post by:
Error in msvc in building inheritance.obj to build hello.pyd
Hello,
I am trying to build the boost 1.31.0 sample extension hello.cpp.
I can not compile the file inheritance.cpp because the two...
|
by: Tony Wright |
last post by:
Hi,
I am having a problem installing an msi for a web site. The error
message I am getting is:
"The specified path 'http://mipdev05/features/Fas2' is unavailable.
The Internet Information...
|
by: Aravind |
last post by:
we have two files:
1. rc4.c (defines one function "create_pin()")
2. MyImpl.c(calling the function "create_pin()"),This implements JNI
method.
1.When I am trying to create .dll file with one...
|
by: deko |
last post by:
I use this convention frequently:
Exit_Here:
Exit Sub
HandleErr:
Select Case Err.Number
Case 3163
Resume Next
Case 3376
Resume Next
|
by: hazz |
last post by:
My runtime in debug is dropping through the constructors from an upper level
class into subclassed constructors.....
namespace AB
public class A : MarshalByRefObject
public A () ...
|
by: p |
last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also
have Crystal 9 pro on my development machine. The web app runs fine on my
dev machine but am having problems deploying....
|
by: .Net Sports |
last post by:
I'm drawing data from xml file, putting it into datarows, from
datatable subroutine (UseXMLDocument) , and I'm getting a
"System.IndexOutOfRangeException: There is no row at position 0" at the
"...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
| |