0

Is it possible to add a dynamic banner field, within a compiled application, that pulls an image and hyperlink from a database on a cloud server somewhere?

I currently have a static banner in my app - using the following code, but I would like to be able to change that at a server somewhere rather than having to create an auto-update for a new sponsor.

private void BannerAd_Click(object sender, EventArgs e)
{
    Process.Start("http://www.DatabaseLinkToSponseredAdvertiserLinkGoesHere");
}
sphair
  • 1,674
  • 15
  • 29
Jeagr
  • 1,038
  • 6
  • 16
  • 30
  • Why not just generate the image on the server side (with ASP.NET or something) and download the image to the c# app? – kor_ Dec 19 '12 at 08:39
  • I'd say add two fields for URL and content, and a three column table in the database (id[int, identity, pk],url,content). on load, make up a random int and pull the corresponding row. you might want a stored proc telling you how many rows you have (so you can pull a random row with no issues) – Alex Dec 19 '12 at 08:39
  • Kor/Alex, do either of you know what Form components I would insert into my app to display the banner? I am fairly decent with static apps, but this is my first foray into remote assets. – Jeagr Dec 19 '12 at 08:42
  • Of course but, what have you tried? How do you connect to your server? – Jodrell Dec 19 '12 at 09:31

1 Answers1

2

It can be done, but what are you using for a DBMS?

For example, at my workplace we are using SQL Server w/T-SQL on my current project, and we use the Image Data Type to help achieve what you are looking for (MSDN Article)

Doing the above can be costly, especially if you have a lot of high-res images. So with that in mind, you could alternatively have a table with a key field and value field that points to the image path on your application server.

e.g.

KEY      |    VALUE
BannerX  |    ~/Images/Sponsored/BannerX.png
BannerY  |    ~/Images/Sponsored/BannerY.png
BannerZ  |    ~/Images/Sponsored/BannerY.png

If you make the Key field the primary key, then you will only need to add future C# code if you add new keys to the Database.

HarbyUK
  • 386
  • 1
  • 5
  • So, use a dictionary list? And point to the image? What about a the corresponding hyperlink? – Jeagr Dec 19 '12 at 09:34
  • Perhaps I should have made it more clear, but this would be a database table such as dbo.sponsored_images. You then have the power either to retrieve them in the C# code by Key, or to get all in a List, and rotate the images at random. – HarbyUK Dec 19 '12 at 09:38