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

  • Home
  • SEARCH
  • 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 8103049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:24:45+00:00 2026-06-05T23:24:45+00:00

How would I go about running a query in asp and storing it in

  • 0

How would I go about running a query in asp and storing it in an array. Then with the array go through each record without having to refresh the page every time.

for example

Sub loaddata()
    Dim conn As New IfxConnection(connectionstring)

    Dim results() As String
    Dim i As Integer = 0

    conn.ConnectionString = connectionstring
    Try
        conn.Open()
        MsgBox("Made connection!")

    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
    Dim cmd As New IfxCommand("Select name from table", conn)
    Dim reader As IfxDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
    While reader.Read()
        results(i) = reader("name")
        i += 1

    End While
    reader.Close()
    conn.Close()
End Sub

The results are stored in results(i)

Say I have a button that says next and everytime I want it to go to the next item in the results array. I don’t want the page to refresh. How do i do that?

  • 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-05T23:24:48+00:00Added an answer on June 5, 2026 at 11:24 pm

    You need to consider how you are going to set up your page. There are many ways to go about doing this.

    If you get all the records on the page load, you can then assign them to their respective controls. To make it appear is if they are on many pages you could use a MultiView control.

    Markup

    <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
       <asp:View ID="View1" runat="server"> 
          <asp:Label ID="lblRecordOne" runat="server" />
       </asp:View>
       <asp:View ID="View2" runat="server"> 
          <asp:Label ID="lblRecordTwo" runat="server" />
       </asp:View>         
    </asp:MultiView>
    <asp:Button ID="btNext" runat="server">Next</asp:Button>
    

    Code-behind

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
         'Call your method that loads the data to results
         Dim results() As String = loaddata()
         'Set the data
         lblRecordOne.Text = results(0)
         lblRecordTwo.Text = results(1)
    End Sub
    
    Protected Sub btNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btNext.Click
    
     'There is a much better way to go about this, but for this 
     'demos sake here is the basic idea
     MultiView1.SetActiveView(View2)
    
    End Sub
    

    What you want to keep in mind is that each View control has an index inside of the MultiView. So you need a way to keep track of what the active view is. When the user clicks the next button you progress the view by one.

    In terms of an MVC application

    Controller

    public class HomeController 
    {
       // /Home/GetRecord/{id}
       public ViewResult GetRecord(int? id)
       {
            int modelID;
            if (id == null) { modelID = 0; }
            ViewBag.CurrentID = modelID;
            // This will send the value to the view
            // I would refactor loaddata to only return one record at a time
            // based on an id or an index
            return View(loaddata(modelID));
       }
    }
    

    View

    <label>@Model.Result</label>
    @Html.ActionLink("GetRecord", "Home", new { id = ViewBag.CurrentID + 1 })
    

    Every time you click on the ActionLink it will progress through the record set by one.

    If the first record is Hello and the second record is World:

    /Home/GetRecord/0 – Hello

    /Home/GetRecord/1 – World

    Sorry that I switched it up to C#, I prefer writing C# by free hand rather than VB. The code is very similar in VB. If you need a converter to go http://converter.telerik.com/.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL query I'm running in an ASP.NET page. The final parsed
in CakePHP how would go about running this query? It's to get the next
I'm wondering how I would go about running two separate queries within one mysqli_result.
How would one go about cancelling execution of a query statement using pyscopg2 (the
I have 30 tables of data that I'm running a query on, and then
Don't know much about running a function on every item in an array, still
Any ideas how I would go about writing a javascript method to insert an
Just a quick question about how you would go about implementing this. I want
I would like to know how I would go about altering the HTML that
I'm wondering how i would go about making the following application: a user signs

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.