How to get values from VFP DB each row n column in VB.NET


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: How to get values from VFP DB each row n column in VB.NET

Threaded View

  1. #1
    Join Date
    Feb 2009
    Posts
    2

    Wink How to get values from VFP DB each row n column in VB.NET

    How to get values from VFP DB each row n column in VB.NET

    Hi
    I am trying and eager to et in to .NET and I have few issues trying to get a program which created to make it work.
    I have a table ex:
    Table user
    Name account TotValue

    John 1234 120.00
    Doe 3423 1129.00
    Axel 6554 2670.00
    Mia 6543 200.00

    I have created a program where when it runs it should read each of the rows TotValue and put them in a special band

    Band 1 = 0 to 200
    Band 2 = 1000 to 2000
    Band 3 = 2000 to 5000

    When run the program it should go through each row and see if the TotValue belongs to any of the given bands and if that’s the case it should count how many should fit in to the given bands criteria.
    In this case
    n
    Band 1 = 0 to 200 = 2
    Band 2 = 1000 to 2000 = 1
    Band 3 = 2000 to 5000 = 1

    This is by codes and I have issues getting it go through each row, on VB6 I used BOF and EOF, but in VB.NET I am not sure how to get this work.
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim conn As Odbc.OdbcConnection
            Dim comm As Odbc.OdbcCommand
            Dim dr As Odbc.OdbcDataReader
            Dim connectionString As String
            Dim sql As String
            Dim ADTotalN1Con1 As Decimal
            Cursor.Current = Cursors.WaitCursor
            ToolStripStatusLabel1.Text = "Calculating ..."
            'Open connection to the ODBC DSN
            connectionString = "DSN=total_value"
    
            sql = "SELECT TotValue from user "
    
            conn = New Odbc.OdbcConnection(connectionString)
            conn.Open()
            comm = New Odbc.OdbcCommand(sql, conn)
            dr = comm.ExecuteReader()
            dr.Read()
    		
            'go through each row of the table and check if the TotValue fit in to any of the bands
            'if so calculate how many of them (n amount) would fit in to each band
            
    I need help here to go through each row and get the value 
    		If TotValue > 0 and TotValue < 200 then 
    			b1=b1 +1 
    		Elseif TotValue > 1000 and TotValue < 2000 then
    			b2=b2+1
    		ElseifTotValue > 2000 and TotValue < 5000 then
    			b3=b3+1
    		End if
            'Close connection
            conn.Close()
            dr.Close()
            comm.Dispose()
            conn.Dispose()
        End Sub
    Any help to get this sorted will be very much appreciated.

    ACF.
    Last edited by Hack; 02-27-2009 at 12:35 PM. Reason: Added Code Tags

Similar Threads

  1. Previous & Next Record
    By nickiii in forum .NET
    Replies: 2
    Last Post: 07-01-2005, 01:03 PM
  2. Over on the MS VB.NET group...
    By Tom Shelton in forum .NET
    Replies: 39
    Last Post: 11-08-2002, 07:23 AM
  3. Replies: 0
    Last Post: 02-11-2002, 03:10 PM
  4. row level triggers
    By Ervin Rodriguez in forum Database
    Replies: 3
    Last Post: 02-07-2002, 07:21 PM
  5. Whats the deal with Fox?
    By Joe C. in forum Talk to the Editors
    Replies: 50
    Last Post: 07-30-2000, 08:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center