-
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 11:35 AM.
Reason: Added Code Tags
-
 Originally Posted by afonseka
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.
Check to see if your reader has any info from the query you ran
Code:
If dr.HasRows = True Then
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Thanks you so much Hack,
I will certainly try this. a few questions, am I to do a loop as I need to check on the each row the TotValue, then this value has to go and check on each condition if it is true increment the counter for the specifick condition and the continue to the second row and like that it should continue until the end of the entire rows on that table? What is the best way to do this?
My apologies fro the trouble
Thanks again
ACF
-
Looping is definately something you want to do. If you give me more specifics on what you need, I could give you more "how to" specifics.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
Similar Threads
-
Replies: 2
Last Post: 07-01-2005, 12:03 PM
-
By Tom Shelton in forum .NET
Replies: 39
Last Post: 11-08-2002, 06:23 AM
-
By Traci Butler in forum ASP.NET
Replies: 0
Last Post: 02-11-2002, 02:10 PM
-
By Ervin Rodriguez in forum Database
Replies: 3
Last Post: 02-07-2002, 06:21 PM
-
By Joe C. in forum Talk to the Editors
Replies: 50
Last Post: 07-30-2000, 07: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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks