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.OleDbCon nection(st rConn)
objConn.Open()
'--- Create objects ready to Grab Data
Dim objCmd As New System.Data.OleDb.OleDbCom mand("Sele ct * From Titles")
Dim objDA As New System.Data.OleDb.OleDbDat aAdapter()
objDA.SelectCommand = objCmd
'--- Fill the data set
Dim objDS As New System.Data.DataSet()
objDA.Fill(objDS) '--- this is tripping the circuits --
'System.InvalidOperationEx ception' 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
'--- 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.OleDbCon
objConn.Open()
'--- Create objects ready to Grab Data
Dim objCmd As New System.Data.OleDb.OleDbCom
Dim objDA As New System.Data.OleDb.OleDbDat
objDA.SelectCommand = objCmd
'--- Fill the data set
Dim objDS As New System.Data.DataSet()
objDA.Fill(objDS) '--- this is tripping the circuits --
'System.InvalidOperationEx
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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).It em("title" ).ToString ()
strMsg = objDS.Tables(0).Rows(0).It
ASKER
something like
strMsg = objDS.Fields("title").valu