MySQL Connector /NET
Posted: Mon Feb 08, 2010 8:08 pm
I need some help with using the MySQL.Data.Client if anyone knows how to use it.
I am tryin an experiment with an CnS Add-In and I could use some help.
It is a basic Banner Rotator. I have a form on my server for uploading a 468x60 banner to the server and INSERT data into the database. But unlike in PHP where you can SELECT * FROM banners WHERE ID="$ID"; to get all the info in one shot, I havent been able to find a way todo that with the MySQL Connector.NET. From what I can tell the reader.read() can only see one column at a time and not all the columns information from a record without the ID in the first place.
I am using a ORDER BY RAN() LIMIT 0,1 to get the banner image data from the database but then I need to be able to click on the picturebox1 so the user can visit the banners website.
Ideas anyone?
I am tryin an experiment with an CnS Add-In and I could use some help.
It is a basic Banner Rotator. I have a form on my server for uploading a 468x60 banner to the server and INSERT data into the database. But unlike in PHP where you can SELECT * FROM banners WHERE ID="$ID"; to get all the info in one shot, I havent been able to find a way todo that with the MySQL Connector.NET. From what I can tell the reader.read() can only see one column at a time and not all the columns information from a record without the ID in the first place.
I am using a ORDER BY RAN() LIMIT 0,1 to get the banner image data from the database but then I need to be able to click on the picturebox1 so the user can visit the banners website.
Code: Select all
Then I just put
Public Sub GetBanners()
Try
Dim query As String = "SELECT * FROM banners ORDER BY RAND() LIMIT 0,1"
Dim connection As New MySqlConnection(connStr)
Dim cmd As New MySqlCommand(query, connection)
connection.Open()
Dim reader As MySqlDataReader
reader = cmd.ExecuteReader()
While reader.Read()
PictureBox1.Load("http://72.148.214.60/Media/Banners/Images/" + reader(3))
PictureBox1.SizeMode = Windows.Forms.PictureBoxSizeMode.StretchImage
End While
reader.Close()
connection.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Code: Select all
in the UserControl1_Load Event. This works great. But I cant find away to make the banner clickable for the lack of a better word.GetBanners()
Ideas anyone?