Good day,

Just want to ask some help, Please!

I always encounter "Cannot find Table 0" when i call Stored Procedure in DB2 using VB .Net with Ole DBConnection Provider. Here is my code:

  Private Sub cmdPost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPost.Click

        rsSearch = clsDAOMngr.getConfigParam(2)

        For i = 0 To rsSearch.Tables.Count Step 1

        With rsSearch.Tables(0)
        End With


    End Sub


      Public Function getConfigParam(ByVal strParameter As String) As DataSet
        getConfigParam = Nothing
        Dim sProcedure As String = ""

        sProcedure = "EDMS.SAMPLE_SELECT2"

        getConfigParam = clsDBMngr.executeStoredProcedure_split(sProcedure, strParameter, 1)

    End Function


    Public Function executeStoredProcedure_split(ByVal spname As String, ByVal strparam As String, ByVal numberOfSInput As Integer) As DataSet
        executeStoredProcedure_split = Nothing

            command.CommandType = CommandType.StoredProcedure
            command.CommandText = spname
            command.Connection = connection_oledb

                arrStrParam = strparam.Split("|")

            For i = 0 To numberOfSInput - 1 Step 1
                parameterValue = arrStrParam(i)
                command.Parameters(i).Value = parameterValue

            adapter = New OleDbDataAdapter(command)
            executeStoredProcedure_split = New DataSet(command.CommandText)
            Dim dataTable As DataTable = executeStoredProcedure_split.Tables(0)

            Return executeStoredProcedure_split
                MsgBox(Err.Description, MsgBoxStyle.Critical, strtitle)
                Exit Function
            End Try

    End Function

Please help.
Thanks in advance :))

I see a couple of problems that may occur.

First, you need to change this code:

 For i = 0 To rsSearch.Tables.Count Step 1

To this:

 For i = 0 To rsSearch.Tables.Count - 1 Step 1

To safeguard from index out of range.

Second, do you know that the stored procedure is actually returning a value?

Have you fired the store procedure in DB2 to see the data?

This article has been dead for over six months. Start a new discussion instead.