Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7946011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:01:41+00:00 2026-06-04T01:01:41+00:00

I have the following function that returns only the 1st row of data and

  • 0

I have the following function that returns only the 1st row of data and puts it in a nice table. My knowledge in this area is limited in that I don’t know how to create the table to return multiple rows. Can you show me how to change this to return all rows, no matter how many there are? my sql select statement may return 0 rows or many rows.

thanks:

<System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()> _
    Public Shared Function GetDynamicContent(contextKey As String) As String
        Dim constr As String = "Data Source=my data source"
        Dim query As String = "SELECT * FROM Details WHERE ItemID = " & contextKey

        Dim da As New SqlDataAdapter(query, constr)
        Dim table As New DataTable()

        da.Fill(table)

        Dim b As New StringBuilder()

        b.Append("<table style='background-color:#f3f3f3; border: #336699 3px solid; ")
        b.Append("width:350px; font-size:10pt; font-family:Verdana;' cellspacing='0' cellpadding='3'>")

        b.Append("<tr><td colspan='3' style='background-color:#336699; color:white;'>")
        b.Append("<b>Budget Item Details</b>")
        b.Append("</td></tr>")
        b.Append("<tr><td style='width:80px;'><b>Detail</b></td>")
        b.Append("<td style='width:80px;'><b>Amount</b></td>")
        b.Append("<td><b>Date</b></td></tr>")

        b.Append("<tr>")
        b.Append("<td>$" & table.Rows(0)("Detail").ToString() & "</td>")
        b.Append("<td>" & table.Rows(0)("Amount").ToString() & "</td>")
        b.Append("<td>" & table.Rows(0)("DetailDate").ToString() & "</td>")
        b.Append("</tr>")

        b.Append("</table>")

        Return b.ToString()
    End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:01:42+00:00Added an answer on June 4, 2026 at 1:01 am

    Try this. You need a FOR loop to create rows.

    Public Shared Function GetDynamicContent(contextKey As String) As String
      Dim constr As String = "Data Source=my data source"
      Dim query As String = "SELECT * FROM Details WHERE ItemID = " & contextKey
      Dim da As New SqlDataAdapter(query, constr)
      Dim table As New DataTable()
      da.Fill(table)
      Dim b As New StringBuilder()
      b.Append("<table style='background-color:#f3f3f3; border: #336699 3px solid; ")
      b.Append("width:350px; font-size:10pt; font-family:Verdana;' cellspacing='0' cellpadding='3'>")
      b.Append("<table style='background-color:#f3f3f3; border: #336699 3px solid; ")
      b.Append("width:350px; font-size:10pt; font-family:Verdana;' cellspacing='0' cellpadding='3'>")
      b.Append("<tr><td colspan='3' style='background-color:#336699; color:white;'>")
      b.Append("<b>Budget Item Details</b>")
      b.Append("</td></tr>")
      b.Append("<tr><td style='width:80px;'><b>Detail</b></td>")
      b.Append("<td style='width:80px;'><b>Amount</b></td>")
      b.Append("<td><b>Date</b></td></tr>")
      For i As Integer = 0 To table.Rows.Count-1
        b.Append("<tr>")
        b.Append("<td>$" & table.Rows(i).Cell("Detail").ToString() & "</td>")
        b.Append("<td>" & table.Rows(i).Cell("Amount").ToString() & "</td>")
        b.Append("<td>" & table.Rows(i).Cell("DetailDate").ToString() & "</td>")
        b.Append("</tr>")
      Next
      b.Append("</table>")
      Return b.ToString()
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function that is pulling data from a database. The ajax
I have the following function that I only want to run inside <div id=imgWrapper>
Assume i have the following function: def select_queryset(value_to_decide_upon): this function returns either any of
I have a JavaScript function that returns a string. I want to write this
I have the following function that deletes the LaTeX command surrounding the current cursor
I have the following function that I am using to remove the characters \04
I have the following function that takes a number like 5 and creates a
I have the following function that retrieves an image from a twitter feed, the
I have the following function that is supposed to trigger anytime one of the
I have the following structure and function that adds things to the structure: struct

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.