Table : Index was outside the bounds of the array error

Hi,

I have database table with 80 column, I want to dump the all columns into PDF file. while setting pdf column widths I am getting "Index was outside the bounds of the array " error message.

Any help to fix this issue? Is there a better way to create pdf file from the database.

Thanks
Sundaram


===============


Public Sub dbread()

Dim conString As String = “Data Source=.;Initial Catalog=leodb; UID=leodbuser; PWD=abc123”

Dim sqlstr As String

Dim objConnection As New SqlConnection(conString)

sqlstr = “select * from staff”

Dim MyDataset As DataSet

Dim MyTable As DataTable

Dim loop1, numrows As Integer

objConnection.Open()

Dim MyCommand As SqlDataAdapter = New SqlDataAdapter(sqlstr, objConnection)

MyDataset = New DataSet

MyCommand.Fill(MyDataset)

MyTable = New DataTable

MyTable = MyDataset.Tables(0)

dbtopdf(MyTable)

objConnection.Close() ’ Close the DB Connection

End Sub

Private Sub dbtopdf(ByVal dt As DataTable)

Try

Dim pdf1 As Pdf = New Pdf

Dim sec1 As Section = pdf1.Sections.Add()

Dim tab1 As Aspose.Pdf.Table = New Aspose.Pdf.Table

sec1.Paragraphs.Add(tab1)

Dim i As Integer

Dim colwidth As String

colwidth = “”

For i = 0 To dt.Columns.Count - 1

If dt.Columns(0).DataType Is System.Type.GetType(“system.datetime”) Then

colwidth = colwidth & " 50 "

Else

colwidth = colwidth & " 30 "

End If

Next

'tab1.ColumnWidths = " 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 "

tab1.ColumnWidths = colwidth

tab1.DefaultCellBorder = New BorderInfo(CType(BorderSide.All, Integer), 0.1F)

tab1.ImportDataTable(dt, True, 0, 1, 3, 3)

Dim row1 As Row = tab1.Rows(0)

Dim curCell As Cell

For Each curCell In row1.Cells

curCell.BackgroundColor = New Aspose.Pdf.Color(“Blue”)

Next

pdf1.Save(“c:\test2.pdf”)

Catch ex As Exception

Label1.Text = ex.Message

End Try

End Sub


Dear Sundaram,

Thank you for considering Aspose.

This bug has been fixed, please download hot fix here.