Steve Villiers
9/10/2002 2:24:00 AM
Hi Dave and Dave,
Thanks for your responses. Between the two I was able to
nut out the problem.
Unfortunately, it is so simple it's very embarassing to
reveal.
-> The table name needs to be qualified with the
library/environment.
ie: not "from myTable", but "from myLibrary.myTable",
since DB2 allows multiple tables in the same database with
the same name, and gets confused sending back nothing.
(Mind you, I would've expected an error in this case,
but...)
Again, thanks guys. You each provided a clue.
Simon.
>-----Original Message-----
>Hi guys,
>
>I'm using VB.NET with ODBC to access a DB2 database
>running on an AS400. I have a system DSN set up through
>the control panel using a DB2 provider from IBM.
>
>Setting up DB2 through the Server Explorer option, I can
>right-click the table and choose "Retrieve Data from
>Table" successfully.
>
>However, if I use code then no dataset is returned.
>Peforming the ODBCDataReader.Read() function to return
the
>first row results in nothing.
>
>Any ideas??
>
>I have posted the code below for anyone who is interested.
>
>Simon.
>
>Module FileProcessor
>
> Dim myConnection As New OdbcConnection
>("Provider=MSDASQL.1;DSN=myDB2")
>
> Public Function TestODBC()
> Dim myCommand As OdbcCommand
> Dim myReader As OdbcDataReader
> Dim RetVal As Object
> Try
> myConnection.Open()
> myCommand = myConnection.CreateCommand()
> myCommand.CommandText = "Select * from
>Accounts"
> myReader = myCommand.ExecuteReader
> MsgBox(myReader.FieldCount) ' this works
> RetVal = 0
> While myReader.Read() ' count no. of rows
> RetVal = RetVal + 1 ' never get here
> End While
> MsgBox(RetVal)
> myConnection.Close()
> Catch err As Exception
> MsgBox(err.Message)
> End Try
> End Function
>End Module
>
>
>.
>