سؤال

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");
}
هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top