All what I did for this to work is the following
1. Created a Table in my database to store (ID, AdName, AdImageURL, AdURL)
2. Create a DataSet conection to this Table
3. Create a Class to be used for Random Webpage Ads in VB2005.
Public Class WebAds
Public URLref As String
Public URLimg As StringSub GetAds()
Dim DSWebAds As New WebAds 'DatasetDim DSwebAdsTableAdapter As New WebAdsTableAdapters.WEB_ADSTableAdapter
DSwebAdsTableAdapter.Fill(DSWebAds.WEB_ADS)
Dim AdNumber As Integer = DSWebAds.WEB_ADS.Rows.Count
Randomize()
AdNumber = CInt(Int((AdNumber - 1 + 1) * Rnd() + 1)) - 1
URLimg = DSWebAds.WEB_ADS.Item(AdNumber).adIMG.ToString
URLref = DSWebAds.WEB_ADS.Item(AdNumber).adURL.ToString
End Sub
End
Class
4. Now in the form I insert an Image Object to retain the image once loaded.
5. Public a variable
Public USR_MENUads As New WebAds
6. In the form Activated code I type:
USR_MENUads.GetAds()
AdPicture.ImageLocation = USR_MENUads.URLimg
AdPicture.Refresh()
7. in the Image Click event type:
Process.Start(USR_MENUads.URLref)
Note: Remember to change the move over to the "hand" to make it look better :)
Enjoy!