uberamd
Member
- Joined
- Jan 22, 2007
- Messages
- 9
- Programming Experience
- Beginner
Alright, I have stated in a previous post that my Visual Basic .NET book does not cover databases in depth at all. So I have been using google to get my answers, however cant find a very simple answer: How do I loop through a database, grab a value, and use it?
For example I want to grab a value from a row, and use a equation to manipulate it.
In PHP, I would do it similar to this:
Thats not exactly how it would be modeled in PHP, but a general idea. Basicly I need my query which is SELECT x, y FROM account to loop through each row, take x from the database and manipulate it like so: (800/16400)*x + 400 and then set that as x1, then take the y that is in the same row, and manipulate it like so: (815/16400)*y + 407.5 and then set that as y1, then run this to plot the point:
Im sorry if this is hard to understand I will summarize:
A) How do I loop through rows in a mysql database query
B) I need to take the value of each row and run the equation's above on the x and y value
C) I need to run the above graphics sub to draw the point
D) Loop and do the same with the next point
This probably is VERY easy, I just need some help getting on track.
For example I want to grab a value from a row, and use a equation to manipulate it.
In PHP, I would do it similar to this:
PHP:
<?php
$result = mysql_query("SELECT x, y FROM locations") or die(mysql_error());
$row_count = mysql_num_rows( $result );
$i == 0;
while($i < $row_count)
{
$row = mysql_fetch_array( $result );
$newx = (800/16400)* $row['x'] + 400;
$newy = (815/16400)* $row[y'] + 407.5;
// METHOD HERE TO DRAW CIRCLE
$i++;
}
?>
Thats not exactly how it would be modeled in PHP, but a general idea. Basicly I need my query which is SELECT x, y FROM account to loop through each row, take x from the database and manipulate it like so: (800/16400)*x + 400 and then set that as x1, then take the y that is in the same row, and manipulate it like so: (815/16400)*y + 407.5 and then set that as y1, then run this to plot the point:
VB.NET:
Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
Dim g As Graphics = pe.Graphics
Dim fnt As New Font("Verdana", 10)
g.DrawString("First Last", fnt, New SolidBrush(Color.Red), x+6, x-5)
Dim pn As New Pen(Color.Red, 5)
Dim rect As New Rectangle(x, y, 5, 5)
g.DrawEllipse(pn, rect)
End Sub 'OnPaint
Im sorry if this is hard to understand I will summarize:
A) How do I loop through rows in a mysql database query
B) I need to take the value of each row and run the equation's above on the x and y value
C) I need to run the above graphics sub to draw the point
D) Loop and do the same with the next point
This probably is VERY easy, I just need some help getting on track.