question

Dikshadudi-8186 avatar image
0 Votes"
Dikshadudi-8186 asked Dikshadudi-8186 commented

how to add images dynamically to adrotator using database in vb.net?

i want to add images from table mainindex_img dynamically to adrotator.
195627-screenshot-99.png


here at the top after the header

195691-screenshot-100.png


dotnet-aspnet-generaldotnet-aspnet-webformsdotnet-aspnet-webpages
screenshot-99.png (300.9 KiB)
screenshot-100.png (1.3 MiB)
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You did not share any code so it's impossible to figure out what the actual problem is. My best guess is the unknown add rotator you are using wants a URL to get the image(s) and that's where you are stuck. The standard approach in Web Forms is to create an image handler. An image handler is just a URL that executes custom logic that you get to write for fetching an image. Do an internet search and you'll find tons of examples. Image handler are very common in Web Forms.

https://www.google.com/search?q=asp.net+image+handler

Going forward please ask specific questions and stop tagging Web Forms questions as aspnet Core. As explained in your other thread(s), Web Forms does not exist in aspnet Core. When forum members click on aspnet Core we see your off-topic Web Forms questions.



0 Votes 0 ·

Vb. Net is also the part the of asp. Net and these server side controls are also the part of asp. Net ok. I am not tagging irrelevantly.

0 Votes 0 ·
AgaveJoe avatar image AgaveJoe Dikshadudi-8186 ·

Vb. Net is also the part the of asp. Net and these server side controls are also the part of asp. Net ok. I am not tagging irrelevantly.

You are mistaken. .NET Core is the latest development platform and does not include Web Forms or VB.NET web applications. ASP.NET Core has MVC and Razor Pages.

Overview to ASP.NET Core

The old .NET Framework, the platform you are targeting, includes Web Forms and VB.NET. This information is openly documented.

Did you at least try to write an image handler? Are you able to fetch the image for the database? What add rotator are you using?


0 Votes 0 ·
Show more comments

1 Answer

LanHuang-MSFT avatar image
0 Votes"
LanHuang-MSFT answered Dikshadudi-8186 commented

Hi @Dikshadudi-8186,
Can you describe your needs in more detail? What does each data in the database mean?
I guess you might want to use AdRotator with a database, you can refer to the code below.

   <asp:AdRotator id="AdRotator1" runat="server"/>

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
         Using con As SqlConnection = New SqlConnection("****")   
             Using cmd As SqlCommand = New SqlCommand("SELECT * FROM mainindex_img", con)
                 Dim sda As SqlDataAdapter = New SqlDataAdapter(cmd)
                 Dim dt As DataTable = New DataTable()
                 sda.Fill(dt)
                 AdRotator1.DataSource = dt
                 AdRotator1.DataBind()
             End Using
         End Using
     End Sub

Best regards,
Lan Huang


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for your reply. I'll try this

0 Votes 0 ·

Actually i want this image to change on every on refresh which is coming from database.
But my problem is solved by sql query command ORDER BY NEWID(), which gives random output on every refresh.

196045-img20220425140816.jpg


0 Votes 0 ·

Hi @Dikshadudi-8186,
The AdRotator control displays a randomly selected ad banner on a web page. Every time the page is refreshed, the displayed ad changes.
For details, you can check the documentation.
https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.adrotator?view=netframework-4.8
Best regards,
Lan Huang

0 Votes 0 ·

Yes i know that's why i want to use adrotator, but it is solved without it

0 Votes 0 ·