Avatar of okcuser
okcuser

asked on 

Using table adaptor to loop through recordset

I'm trying to make a big leap here from Visual Basic 6 / Interdev 6 to Visual Studio 2005 .Net and I'm struggling because things have changed a lot!  

I have developing a simple windows CE 5 application using Visual Studio.  I have managed to create a SQL CE database on my mobile and create the dataset and table adaptor.   In this code I am trying to insert a record into my local ce database and then loop through the database to read all the records in it.   I'm getting an error on the "as DataRow" that "Type DataRow is not defined".  

I'd appreciate any feedback on why the error and if I am doing this correctly.


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim offlineClockData As New OnyxCEDataSet
        Dim offlineTableAdaptor As New OnyxCEDataSetTableAdapters.tblOfflineClockDataTableAdapter
        Dim vEID As String

        offlineTableAdaptor.Insert(Now(), "977111", "117273", 1)

        offlineTableAdaptor.Fill(offlineclockdata.tblOfflineClockData)

        For Each objRow As DataRow In offlineClockData.tblOfflineClockData.Rows
            vEID = objRow("EID")
        Next

        vEID = offlineclockdata.tblOfflineClockData.Rows(0).Item("EID")

    End Sub
Smartphone ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
okcuser
Avatar of okcuser
okcuser

ASKER

Well, I got it working like this:

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim offlineClockData As New OnyxCEDataSet
        Dim offlineTableAdaptor As New OnyxCEDataSetTableAdapters.tblOfflineClockDataTableAdapter
        Dim vEID As String
        Dim i As Long

        offlineTableAdaptor.Insert(Now(), "977111", "117273", 1)

        offlineTableAdaptor.Fill(offlineClockData.tblOfflineClockData)

        For i = 0 To offlineClockData.tblOfflineClockData.Rows.Count() - 1
            vEID = offlineClockData.tblOfflineClockData.Rows(i).Item("EID")
            MsgBox("veid=" & vEID)
        Next

    End Sub

Does this look correct or is there a better way to do it?  Also, do I need to "Close" the connections?  
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of okcuser
okcuser

ASKER

Thanks!
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo