Link to home
Start Free TrialLog in
Avatar of Hiddenattractor
Hiddenattractor

asked on

Getting tripped out here -- need some help

  Protected Function GetData() As System.Data.DataSet
        '--- Function returns a DataSet containing information
        Try
            '--- connection string
            Dim strConn As String = "Provider"  '--- connection works

            '--- create data object
            Dim objConn As New System.Data.OleDb.OleDbConnection(strConn)
            objConn.Open()

            '--- Create objects ready to Grab Data
            Dim objCmd As New System.Data.OleDb.OleDbCommand("Select * From Titles")
            Dim objDA As New System.Data.OleDb.OleDbDataAdapter()
            objDA.SelectCommand = objCmd

            '--- Fill the data set
            Dim objDS As New System.Data.DataSet()
            objDA.Fill(objDS)                                '--- this is tripping the circuits --
                                                                       'System.InvalidOperationException' occurred in
                                                                        System.Data.dll


            '--- clean up and return the Dataset
            objConn.Close()

            Dim strMsg As String

            strMsg = objDS.Tables.Count

            MsgBox(strMsg)




            Return objDS


        Catch
            '--- possible errors include Excel file already open and locked, et al
            Return Nothing
        End Try

    End Function
ASKER CERTIFIED SOLUTION
Avatar of TSmooth
TSmooth

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hiddenattractor
Hiddenattractor

ASKER

That Worked great but how can I now change the strMsg = objDS.Tables.count to
something like
strMsg = objDS.Fields("title").value '--- I used to use this with ADO 2.0
what do you want strMsg to be? If you want it to be the value of a column from one of the rows of your data table you'd do something like this to get the first row's column "title" value:

strMsg = objDS.Tables(0).Rows(0).Item("title").ToString()