Click to See Complete Forum and Search --> : Connecting to a MySQL database...


YourSurrogateGod
September 11th, 2005, 09:38 PM
Pretty much what I'm trying to do is grab some data off of an online database, store it in a data set and then try to convert it to a one long string so that I can stick it in a list. My friend showed me something similar to the below, but it doesn't compile. Anyone know how to make this work correctly?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Dim conn As New MySql.Data.MySqlClient.MySqlConnection("****")
Dim ds As New DataSet

Dim da As New MySql.Data.MySqlClient.MySqlDataAdapter("SELECT * FROM Sensor_Data", conn)
conn.Open()
da.Fill(ds, "Sensor_Data")
conn.Close()

Dim test As String

Try
test = ds.Tables("Sensor_Data").Rows.Item("data_id").Table.ToString & " " & _
ds.Tables("Sensor_Data").Rows.Item("sensor_address").Table.ToString() & " " & _
ds.Tables("Sensor_Data").Rows.Item("value").Table.ToString() & " " & _
ds.Tables("Sensor_Data").Rows.Item("timestamp").Table.ToString()
Catch ex As Exception
MessageBox.Show(ex.ToString, "An error has occured with the database conneciton.", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

For Each myrow As DataRow In ds.Tables("sensor_data").Rows
ListBox1.Items.Add(test)
Next
End Sub
The reason why I posted this here is because it has more to do with the way the language works rather than database design.

YourSurrogateGod
September 11th, 2005, 10:10 PM
Never mind, figured it out...