Page 1 of 1

MySQL Connector /NET

Posted: Mon Feb 08, 2010 8:08 pm
by Scottie1972
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.
Code: Select all
 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
Then I just put
Code: Select all
GetBanners()
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.

Ideas anyone?

Re: MySQL Connector /NET

Posted: Mon Feb 08, 2010 10:27 pm
by CodenStuff
Hello,

I dont know about the MySQL stuff but casirus is making something with the connector so perhaps he will know.

Cant you use the "PictureBox1_Click" event?. Like when you load the banner into the picturebox you also get the URL of where the banner goes too. Store it in a string or the PictureBox1.Tag then when the user clicks the picturebox use:
Code: Select all
SlotAddin.Interaction.GoURL(PictureBox1.Tag.Tostring)
- To use the CnSDesktop browser or
Code: Select all
Process.Start(PictureBox1.Tag.Tostring)
to open the link in a seperate window.

Hope that helps cooll;

Re: MySQL Connector /NET

Posted: Tue Feb 09, 2010 12:48 am
by Scottie1972
dude, great idea! I didnt think about that.
Just save the URL from the database to a setting then put the setting in the click event....so simple! Way cool!?!?!

Re: MySQL Connector /NET

Posted: Tue Feb 09, 2010 1:03 am
by Scottie1972
CodenStuff wrote:
Hello,

I dont know about the MySQL stuff but casirus is making something with the connector so perhaps he will know.

Cant you use the "PictureBox1_Click" event?. Like when you load the banner into the picturebox you also get the URL of where the banner goes too. Store it in a string or the PictureBox1.Tag then when the user clicks the picturebox use:
Code: Select all
SlotAddin.Interaction.GoURL(PictureBox1.Tag.Tostring)
- To use the CnSDesktop browser or
Code: Select all
Process.Start(PictureBox1.Tag.Tostring)
to open the link in a seperate window.

Hope that helps cooll;

I tried using
Code: Select all
SlotAddin.Interaction.GoURL(PictureBox1.Tag.Tostring)
in the click event but it errored saying 'Interaction' is not a member of 'SlotAddin'
so I ended up doing
Code: Select all
Process.Start(My.Settings.bannerurl)
to open the users default browser. I hate that too. I would like it to open in the CnS Browser.

Now all I have todo is get the tooltip to show the Title and where good togo.

Re: MySQL Connector /NET

Posted: Tue Feb 09, 2010 10:36 am
by CodenStuff
Hello,

I think you get that error because it using the old AppGlue.dll file, re-reference it using the AppGlue.dll file in your CNSDesktop folder because its been updated with new code.

Re: MySQL Connector /NET

Posted: Tue Feb 09, 2010 4:30 pm
by Scottie1972
CodenStuff wrote:
Hello,

I think you get that error because it using the old AppGlue.dll file, re-reference it using the AppGlue.dll file in your CNSDesktop folder because its been updated with new code.
That did the trick. Thanks.

Re: MySQL Connector /NET

Posted: Sat Feb 20, 2010 12:16 am
by Nery
Solved - Topic Closed