Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess
Go Back  Xtreme Visual Basic Talk > > > Question about For ...i in connectioin with DBaccess


Reply
 
Thread Tools Display Modes
  #1  
Old 09-27-2008, 04:57 PM
nader75 nader75 is offline
Centurion
 
Join Date: Feb 2004
Posts: 181
Question Question about For ...i in connectioin with DBaccess


How can I make the code by using For...i check the data to the last Row?
Code:
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" _
        & "Data Source =" & Application.StartupPath & "\Data.mdb ")
        Dim sql As String = " Select * from Table1 Where kind='sell' and Name='pump' "
        conn.Open()
        Dim dp As New OleDbDataAdapter(sql, conn)
        Dim ds As New DataSet
        dp.Fill(ds, "Table1")
        Dim i As Integer
        For i = 1 To 4
            Dim adi As New ListViewItem(ds.Tables(0).Rows(i).Item("number").ToString)
            adi.SubItems.Add(ds.Tables(0).Rows(i).Item("kind").ToString)
            adi.SubItems.Add(ds.Tables(0).Rows(i).Item("Name").ToString)
            ListView1.Items.Add(adi)
        Next i
        conn.Close()
        ListView1.View = View.Details
Reply With Quote
  #2  
Old 09-27-2008, 08:17 PM
AaronKimbrough AaronKimbrough is offline
Freshman
 
Join Date: Aug 2008
Posts: 30
Default

I'm not sure about the DataSet collection, but for the RecordSet collection (ADO, DAO, and ADODB) you can use the BOF, EOF and Bookmark properties to identify the Beginning of the Field, the End of Field, and the current position in the field. The DataSet collection should have similar properties you could use, although I can not verify that just now as the computer I am using does not have vb, only vba.

Using these properties of RecordSet you would simply declare the follwing:

Code:
Do Until RecordSetName.EOF
     ' do something here
loop
Or

Code:
Do While RecordSetName.EOF=False
loop
Or

Code:
Do While Not RecordSetName.EOF
loop
These methods will loop through all rows of the recordset until it reaches the end of the field. EOF is set to true upon moving past the last record in the collection.

Check to see if the DataSet collection has any similar properties that will allow the same type of functionality.

Tip: I find the object browser comes in very handy for identifying all the various components that make up a class. Good for finding useful properties and such.
Reply With Quote
  #3  
Old 09-28-2008, 10:08 AM
nader75 nader75 is offline
Centurion
 
Join Date: Feb 2004
Posts: 181
Default

Yes, But I don't know how to use it with dataset in my code.
Reply With Quote
  #4  
Old 09-29-2008, 12:04 AM
AaronKimbrough AaronKimbrough is offline
Freshman
 
Join Date: Aug 2008
Posts: 30
Default

Here is an example I got off of the MSDN help files.
Code:
Private Sub PrintRows(ByVal dataSet As DataSet)
   Dim table As DataTable
   Dim row As DataRow
   Dim column As DataColumn
   ' For each table in the DataSet, print the row values.
   For Each table in dataSet.Tables
      For Each row In table.Rows
         For Each column in table.Columns
            Console.WriteLine(row(column))
         Next column
      Next row
   Next table
End Sub
This information can be found at the following link:
ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/fxref_system.data/html/dd996d4d-97fa-0416-d022-02e691948be1.htm#exampleToggle
Reply With Quote
  #5  
Old 09-29-2008, 11:26 AM
nader75 nader75 is offline
Centurion
 
Join Date: Feb 2004
Posts: 181
Default

Here is the simple solution for my code:
Quote:
For i = 0 To ds.Tables(0).Rows.Count - 1
Thank you all for help!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess
 
Question about For ...i in connectioin with DBaccess
Question about For ...i in connectioin with DBaccess
 
-->