MySQL Connector /NET

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
7 posts Page 1 of 1
Contributors
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

MySQL Connector /NET
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?
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: MySQL Connector /NET
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;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: MySQL Connector /NET
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!?!?!
Image
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: MySQL Connector /NET
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.
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: MySQL Connector /NET
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.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: MySQL Connector /NET
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.
Image
User avatar
Nery
Co-Admin Moderator
Co-Admin Moderator
Posts: 1117
Joined: Mon Sep 07, 2009 8:11 pm

Re: MySQL Connector /NET
Nery
Solved - Topic Closed
7 posts Page 1 of 1
Return to “Tutorial Requests”