using two arrays for two different fields

I'm trying to extract all the dates from a db table and load them in an array(seems the most logical).  However I keep getting the following error:

Index was outside the bounds of the array.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error:

Line 130:            For Each row In DsVacationData1.RequestDataManager
Line 131:                reqData(x) = row.Item(1)
Line 132:                endData(y) = row.Item(2)
Line 133:                reqDays(reqData(x).Month, reqData(x).Day) = row.Item(8).ToString + " " + row.Item(9).ToString
Line 134:                endDays(endData(y).Month, endData(y).Day) = row.Item(8).ToString + " " + row.Item(9).ToString

This however is not making sense to me, as to why it's throwing the error.  Any insight would be helpful.  Here is my code for the section.

Dim x, y As Int32
Dim reqDays(12, 31), endDays(12, 31) As String
----------------------------------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
      approvalBind()
      Dim row As DataRow
      Dim reqData(x) As Date
      Dim endData(y) As Date
      x = 0
      y = 0
      For Each row In DsVacationData1.RequestDataManager
            reqData(x) = row.Item(1)
            endData(y) = row.Item(2)
            reqDays(reqData(x).Month, reqData(x).Day) = row.Item(8).ToString + " " + row.Item(9).ToString
            endDays(endData(y).Month, endData(y).Day) = row.Item(8).ToString + " " + row.Item(9).ToString
            x += 1
            y += 1
      Next
      Session("Requests") = reqDays
      Session("endRequests") = endDays
End If
End Sub
My Regards to All,
Jason -- O-H-I-O Go Buckeyes! #1
--- LIVESTRONG.ORG --- Please support the battle against cancer!
0
onewisehobbit
3/27/2006 1:21:25 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

2 Replies
611 Views

Similar Articles

[PageSpeed] 48

It's hard to tell just by looking at the code but:

if the date really on the third row ? row.Item(2) (index stars at 0)

Dim endData(y) As Date, if y at a valid length, maybe you should set at the number of dates you have total.


Puzzles, brain teases, riddles, enigmas: http://www.toysforthebrain.com
0
ThE_lOtUs
3/27/2006 5:00:49 PM
Ok I got it---it seems .net doesn't like the x/y not being set to specific size.  SO I just dumped in code to finish out the endDays as I had done for the reqDays and it works fine now.
My Regards to All,
Jason -- O-H-I-O Go Buckeyes! #1
--- LIVESTRONG.ORG --- Please support the battle against cancer!
0
onewisehobbit
3/27/2006 5:04:22 PM
Reply:

Similar Artilces:

Automatically caculate two values that are entered into two different fields and displayed in a Third Field
 Hello, I use the following code in a GridView page to caculate two values that are entered into two different fields and the result is displayed in the TotalHoursPerUnit field.  I am trying to convert the Code Behind The Page to work under the Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBound, but no luck.  Please suggest a way to modify the statements to work with text boxes in a FormView control. Thank you in advance, ASPX Page <script language ="javascript"  type="text/javascript&qu...

How to get data from two different tables for two different columns of a gridview based on datakey
Hi All,            I have a Gridview with two different columns- "Faculty" coming from tblFaculty and "Teachers" coming from tblFacultyTeacherLink. I want to get data for "Teachers" by comparing FcaultyId in tblFacultyTeacherLink and then getting Teachers name. How to achieve this without using nested gridviews?  My .aspx Page is as-   <asp:GridView ID="gviewFaculty" DataKeyNames="FacultyId" AutoGenerateColumns="false" runat="server" Width="100%&q...

how do i link two different sitemap with the use of menu control in one .aspx file to two different hyperlink in the master page?
I have two menu control with similar file(eg.defect.aspx) in the master page, whenever i click the similar file(eg.defect.aspx) in either menu control, it will show both the menu control(eg.student menu and staff menu), but i only want to show only either one of the menu (eg,student menu only). Is there any solution to my problem? Am i able to use similar file(eg.defect.aspx) for two different sitemap and two menu control and only show one menu control. Hey, What should or should not be visible; the whole menu, or the selected field?  Are you h...

How can I get two values from two different data grid???
  I have two datagrids on  one page. How can I get two values from these two datagrid then multiple or add There is data grid A and B . But i want to get values  using cells from e.Item.Cells[1].Text=totalamount.ToString(); from  datgrid and another cell from other data grid then add or divide.How can I achieve this?? int total = int.Parse(Grid1.Items[INDEX].cells[1].Text) + int.Parse(Grid2.Items[INDEX2].cells[1].Text);If you dont know which Item to access use foreach loop for  Grid.ItemsIf this solves your problem please mark as answer  it is com...

testing two three two three two two
Test ...

Loading the two datatables from a dataset in to two different excel sheets using OleDbAdapter
Hi,   I have a problem now, I just created two excel sheets and I loading the data to a datatable in a dataset. If the rows are greater than 65536, then I load the remaining in the second datatable of a dataset. But while calling the update method of OledbAdapter after the first sheet get filled it throws error as "Spreadsheet is full". OledbAdapter.Update(dataset) or even I tried OledbAdapter.Update(datatable). Since i m not using insert query to insert in to the datatable. I have a dataset which I got from someother data and using that dataset i want to fill another ...

Combining two different datasoruces from two different servers?
Hi I'm triying to combine two different sql datasoruces which are from two different sql servers. But I can't seem to get it work I would appreciate any help you guys can provide. Here is my code so far. Dim PCconnectionString As String = ConfigurationManager.ConnectionStrings("CenterConnectionString").ConnectionStringDim TCconnectionString As String = ConfigurationManager.ConnectionStrings("CoreConnectionString").ConnectionString Dim PCcon As SqlConnection = New SqlConnection(PCconnectionString)Dim TCcon As SqlConnection = New SqlConnection(TCconnectionString) Dim sqlPC As String = "S...

access two different folder for two different group of users
Hi: I have a website, teachers and students can login and access their pages: if user is a teacher, he/she can access pages in Folder: "Teacher" only, if student, then can access folder "Student" only. I am using Membership login function, easy to use, but if a student or a teacher login successfully, he/she can access both "Teacher" and "Student" folders. I need find a good way that: if login is a student (I can find way to get that), the user can access "student" folder only. if login is a teacher (I can also using code to get that) ...

Getting results of 2 items in querystring using two different sqldatasources
Hi, I'm using the following to send two items in the querystring over to the next page, where I can display tables based on them. Both querystrings appear fine in the URL. The first querystring works fine to single out the order specified by the orderid from the querystring, but I can't seem to get my other sqldatasource to show the userid (+contents of aspnet_users table) using the userid I passed in the querystring. <asp:HyperLinkField DataNavigateUrlFields="OrderID,UserId" DataNavigateUrlFormatString="Copy of Orders.aspx?OrderID={0}&UserId={1}" DataTextF...

Do's anyone know how to store to two seperate lines into an array and get printed to std out as two seperate lines
Hello, Do's anyone know how to store to two seperate lines into an array and when printed looks like: Hello Bob Goodbye Bob Many Thanks Perl Experts aka carlos Why not use the /n as part of the string? $var = $string1/n$string2; (or something similar) Chris At 06:25 PM 10/8/2001, AMORE,JUAN (HP-Roseville,ex1) wrote: >Hello, >Do's anyone know how to store to two seperate lines into an array >and when printed looks like: >Hello Bob >Goodbye Bob >Many Thanks Perl Experts >aka carlos > > > >-- >To unsubscribe, e-mail...

printing in two different printer for two different datawindows but from one screen
Hi all Our cilent has asked for facitly from a perticular screen that the two different report sholud be printed on two different printer from two different datawindows when a form is filled. First of all is it possible. and if possible pl reply. i tried to go by <DW Control Name>.Object.DataWindow.Printer but later after studying help file i come to know that this function is descibe onle i.e modify function can not be appled. Reagards Trilok Rawat Yes, it is very much possible....go to www.powerwhizz.com for printer utility. On Tue, 20 Feb 2001 04:37:...

Need to combine data from two different servers on two different sites.
If I wanted to transfer data from one novell sever to another via crossover cable. both servers are novell 6.5 How do I change my ip setting's on one of the servers in order to copy data. This server is coming from a totally different network in a different ip range. Without using a windows workstation How could I transfer data? say data volume to data volume. or sys public to sys public. I think I have some software packages there. Or if I must use a windows workstation do I need to add this server to the tree in order to have it map the volumes to drive letters then copy ...

Is it possible to insert data (same fields) in two different table using single insert query
Hi Is it possible to insert data (same fields) in two different table using single insert query?I dont want to use procedure. Only plain insert query.thanksKapil Nakerhttp://www.smnetserv.com AFAIK, nope.***********************Dinakar NethiLife is short. Enjoy it.***********************...

how to run two different query at the same time and save result to two different dataset
im using asp.net 2.0 application , and my application interfaces with SQL database. is it possible to run two SQL query and save result of query to two different datset if so , please let me know how to do that, show me the solution thanku maxmax you cant run 2 at the same time (i dont think) but you can run one after the other and save the results to two different data sets. just create a connection issue statement1 and save to dataset issue statement2 and save to dataset 2 close connection thats it. hth, mcm You can have 2 or more SQL queries in the same stored procedure....

Web resources about - using two arrays for two different fields - asp.net.getting-started

Ted Cruz Forgot To Mention That Wall Street Financed His Senate Bid
Ted Cruz, that champion of the little guy, has some 'splainin' to do. The New York Times is reporting a blockbuster of a story about how he financed ...

GoPro shares slide after disappointing revenue estimate
GoPro Inc estimated fourth-quarter revenue below market expectations due to disappointing sales of its action cameras, and said it would cut ...

The Administration's Deceptions Fall Apart Iran Systematically Humiliated American Sailors
First, watch this: Vice President Biden actually claims that Iran behaved the way “ordinary nations” would: One of the boats had engine failure ...

Austin's dancing on David Bowie Street
David Bowie's mourners have left flowers, candles and glitter around the world, but fans want one tribute to be made permanent a street renamed ...

Twitter sued over ISIS attacks
Family of Florida man killed in November terrorist attack sues Twitter, blaming the San Francisco social network for allowing ISIS to use Twitter ...

Is it crazy to buy any Android phone other than Google’s Nexus 5X?
For many hardcore Android fans, only one smartphone brand will do. Google's Nexus handset lineup offers a pure Android experience that is untouched ...

Mayor hopes for fresh start with Chargers on stadium talks
SAN DIEGO (AP) — Mayor Kevin Faulconer left a message for Chargers chairman Dean Spanos on Wednesday, inviting him back to the negotiating table. ...

‘Ride Along 2’ To Sideswipe ‘Star Wars’ At MLK Weekend Box Office – Preview
“It’s going to be a fantastic January,” beamed one distribution chief this morning. Yeah, but next to last January? When we had American Sniper ...

El Chapo Lawyer: Sean Penn Made Up Quote About Drug Confession
A lawyer for El Chapo is strongly disputing one quote Sean Penn attributed to the drug kingpin in his big Rolling Stone interview . Penn wrote ...

Al Jazeera America is shutting down
Adieu, Al Jazeera America, and all the DNA it absorbed from Al Gore's once massively-hyped Current TV. The network's closure is particularly ...

Resources last updated: 1/14/2016 1:14:58 AM