Solved

There is no row at position 1

Posted on 2007-04-03
5
1,064 Views
Last Modified: 2009-12-16
For Index As Integer = 0 To MaxPeriod - 1

' Get date period

StoredProcName = dbName & ".dbo.usp_GetDatePeriodFromTo"

cmd = dbManager.GetStoredProcCommand(StoredProcName)

dbManager.AddInParameter(cmd, "@YEARMONTH", DbType.String, DtPeriod)

DtPeriod = IncrementDate(DtPeriod, DateIndex)

DateIndex = Index + 1

' Put the yearmonth, start date ,and end date in a dataset

Dim myDs As DataSet = dbManager.ExecuteDataSet(cmd)

Dim myTable As DataTable = myDs.Tables(0)

===== > Dim myRow As DataRow = myTable.Rows(Index)

Dim row As DataRow = myTable.NewRow()

row.ItemArray = myRow.ItemArray

Next

Return retVal

End Function
0
Comment
Question by:mathieu_cupryk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 13

Expert Comment

by:dungla
ID: 18848046
Dim myTable As DataTable = myDs.Tables(0)
Dim myRow As DataRow
' check myTable first
If myTable.Rows.Count >= Index Then
 myRow = myTable.Rows(Index)
End If
Dim row As DataRow = myTable.NewRow()
0
 

Author Comment

by:mathieu_cupryk
ID: 18848327
If myTable.Rows.Count >= Index Then
 myRow = myTable.Rows(Index)
End If
Why does this happen?

with with the rows, because there is information to be added.
0
 
LVL 13

Accepted Solution

by:
dungla earned 500 total points
ID: 18848459
I don't know what is Index variable values. Can you show me entire your code (declare Index and assign it value).

I need to check the index of row because maybe your table have number of row less than the value of Index
0
 

Author Comment

by:mathieu_cupryk
ID: 18848538
Here it is.
Private dbManager As Database = DatabaseFactory.CreateDatabase("DevConfigServer")

        Public Function IncrementDate(ByVal DtPeriod As String, ByVal IncrementAmount As Integer) As String
            Dim strResults As String
            Dim intYear As Integer
            Dim intMonth As Integer
            intYear = Int32.Parse(DtPeriod.Substring(0, 4))
            intMonth = Int32.Parse(DtPeriod.Substring(4, 2))
            intMonth += IncrementAmount
            If intMonth > 12 Then
                intYear += 1
                intMonth -= 12
            End If
            strResults = intYear.ToString & intMonth.ToString().PadLeft(2, "0")
            'strResults = intYear.ToString & intMonth.ToString
            Return strResults
        End Function




Public Function GetBusinessCalendarPeriod(ByVal dbName As String, ByVal DatePeriod As String, ByVal txtMaxPeriod As String) As DataTable

Dim retVal As New DataTable("BusinessCalendars")

Dim DtPeriod As String = DatePeriod

Dim MaxPeriod As Integer = Int32.Parse(txtMaxPeriod)

Dim cmd As DbCommand

Dim tmpds As DataSet = New DataSet()

Dim StoredProcName As String = String.Empty

Dim DateIndex As Integer

'We get the divisions

For Index As Integer = 0 To MaxPeriod - 1

' Get date period

StoredProcName = dbName & ".dbo.usp_GetDatePeriodFromTo"

cmd = dbManager.GetStoredProcCommand(StoredProcName)

dbManager.AddInParameter(cmd, "@YEARMONTH", DbType.String, DtPeriod)

DtPeriod = IncrementDate(DtPeriod, DateIndex)

DateIndex = Index + 1

' Put the yearmonth, start date ,and end date in a dataset

Dim myDs As DataSet = dbManager.ExecuteDataSet(cmd)

Dim myTable As DataTable = myDs.Tables(0)

Dim myRow As DataRow = myTable.Rows(Index)  <===========

Dim row As DataRow = myTable.NewRow()

row.ItemArray = myRow.ItemArray

Next

Return retVal

End Function

0
 

Author Comment

by:mathieu_cupryk
ID: 18851033
Good job.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question