03-24-2013, 10:12 AM
Well, your main problem is that you want to use the information retrieved from the database, right? Well, in order to actually use these variables, you must declare them outside your "while" loop. Since they are declared outside your while loop, you are not able to use them in your checkForUpdates call. That's why you were forced to put quotation marks around them, turning them into meaningless Strings, if you will.
Then, once you've moved the creation of your variables, you can directly access them in your checkForUpdates call. See the fixed code below.
[code2=vbnet]Imports MySql.Data.MySqlClient
Public Class updater
Public conn As MySqlConnection
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
conn = New MySqlConnection(ServerString)
Try
conn.Open()
Dim sqlquery As String = "SELECT vlink, dlink, ftpu, dtpp FROM updater"
Dim data As MySqlDataReader
Dim adapter As New MySqlDataAdapter
Dim command As New MySqlCommand
command.CommandText = sqlquery
command.Connection = conn
adapter.SelectCommand = command
data = command.ExecuteReader
Dim vlink As String = ""
Dim dlink As String = ""
Dim ftpu As String = ""
Dim ftpp As String = ""
While data.Read()
If data.HasRows() Then
vlink = data(1).ToString
dlink = data(2).ToString
ftpu = data(3).ToString
ftpp = data(4).ToString
End If
End While
UpdateVB1.checkforupdate(vlink, "0.0.9", dlink, ftpu, ftpp, True)
data.Close()
conn.Close()
Catch ex As Exception
End Try
End Sub[/code2]
Then, once you've moved the creation of your variables, you can directly access them in your checkForUpdates call. See the fixed code below.
[code2=vbnet]Imports MySql.Data.MySqlClient
Public Class updater
Public conn As MySqlConnection
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
conn = New MySqlConnection(ServerString)
Try
conn.Open()
Dim sqlquery As String = "SELECT vlink, dlink, ftpu, dtpp FROM updater"
Dim data As MySqlDataReader
Dim adapter As New MySqlDataAdapter
Dim command As New MySqlCommand
command.CommandText = sqlquery
command.Connection = conn
adapter.SelectCommand = command
data = command.ExecuteReader
Dim vlink As String = ""
Dim dlink As String = ""
Dim ftpu As String = ""
Dim ftpp As String = ""
While data.Read()
If data.HasRows() Then
vlink = data(1).ToString
dlink = data(2).ToString
ftpu = data(3).ToString
ftpp = data(4).ToString
End If
End While
UpdateVB1.checkforupdate(vlink, "0.0.9", dlink, ftpu, ftpp, True)
data.Close()
conn.Close()
Catch ex As Exception
End Try
End Sub[/code2]