Error when doing a Dataset Fill

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Condor76

Thread Starter
Joined
Nov 11, 2005
Messages
17
Hi,

I'm trying to fill a dataset but I'm getting the following Error: "Fill: SelectCommand.Connection property has not been initialized."

This error occurs in the red line of code I have attached below.
Can someone help me understand how to fix this error. Thank you!!!!


Private Sub btnOH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOH.Click
Dim sConnString As String = "dsn=xxx;" & _
"Uid=xxx;" & _
"Pwd=xxx"

Dim ForecastingConn As New OdbcConnection(sConnString)
ForecastingConn.Open()


Dim selectCMD As OdbcCommand = New OdbcCommand("SELECT PRDDTAASI.DCSDIM.ITMID " _
& "FROM PRDDTAASI.DCSDIM ")

selectCMD.CommandTimeout = 30

Dim forecastingDA As OdbcDataAdapter = New OdbcDataAdapter
forecastingDA.SelectCommand = selectCMD

Dim forecastingDS As DataSet = New DataSet
forecastingDA.Fill(forecastingDS, "PRDDTAASI.DCSDIM")
 

Condor76

Thread Starter
Joined
Nov 11, 2005
Messages
17
I did the following and it fixed the error:

Private Sub btnOH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOH.Click
Dim sConnString As String = "dsn=xxx;" & _
"Uid=xxx;" & _
"Pwd=xxx"

Dim ForecastingConn As New OdbcConnection(sConnString)
ForecastingConn.Open()

Dim selectCMD As OdbcCommand = New OdbcCommand("SELECT PRDDTAASI.DCSDIM.ITMID " _
& "FROM PRDDTAASI.DCSDIM ")

selectCMD.CommandTimeout = 30

Dim forecastingDA As OdbcDataAdapter = New OdbcDataAdapter("selectCMD", sConnString)

Dim forecastingDS As DataSet = New DataSet
forecastingDA.Fill(forecastingDS)

ForecastingConn.Close()
ForecastingConn.Dispose()

End Sub



But I now get a different error message: "An unhandled exception of type 'System.Data.Obdc.ObdcException occurred in system.data.dll. System Error.

This error occurs in the same line as before. Any suggestions?

Thank you!
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top