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.