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 8103051
In Process

The Archive Base Latest Questions

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

I am trying to make a simple program to put data from a database

  • 0

I am trying to make a simple program to put data from a database into a javascript array and then display one result in a textbox. Here is what I have so far

        Dim cmd As New IfxCommand("select first 20 fname from table", conn)
    Dim reader As IfxDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
    Dim i As Integer = 0
    While reader.Read()
        ClientScript.RegisterArrayDeclaration("Names", "'" & reader("fname") & "'")
        i += 1


    End While
    Dim cs As StringBuilder = New StringBuilder()
    cs.Append("<script type=""text/javascript\""> function DoIt() {")
    cs.Append("var TheTextBox = document.getElementById(""TextBox1"");")
    cs.Append("TheTextBox.value = Names[0];")
    cs.Append("script>")
    TextBox1.Text = cs.ToString

Here is the asp

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<p>
    <asp:Button ID="Button1" runat="server" Text="Button" onclick = "DoIt"/>
</p>
</form>
</body>
</html>

I am not sure what else I am supposed to do with this.

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

    So you want to display the first name of your selected 20 in the TextBox initially and maybe lazy-load the other from client side via javascript?

    Try this:

    Using cmd = New IfxCommand("select first 20 fname from table", conn)
        Dim tbl = New DataTable
        Using reader = cmd.ExecuteReader()
            tbl.Load(reader)
            If tbl.Rows.Count <> 0 Then
                Dim allNames = From row In tbl
                               Select row.Field(Of String)("fname")
                TextBox1.Text = allNames.First
                ' embed names with quotes and separate the strings by comma '
                Dim embeddedNames = From name In allNames Select String.Format("'{0}'", name)
                ClientScript.RegisterArrayDeclaration("Names", String.Join(",", embeddedNames))
            End If
        End Using
    End Using
    

    Now you only need to implement the javascript function that switches the names if necessary. You can use String split then:

    var allNames = documentGetElementById("Names").value.split(","); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to make a simple bubblesort program. Read in numbers from a
Trying to make a simple program to catalogue books. Something like this, for example:
Trying to make a simple program to catalogue books. Something like this, for example:
I am trying to make a simple program with SFML. So far I have
I am trying to make a simple program that could open a new activity
I'm new to iPhone programming, and I'm trying to make a simple program without
Trying to make simple minesweeper game in python, but have one problem. I have
I'm trying to make simple script using jquery $post function to pass data to
I'm trying to make a simple php script to find all src attributes from
I am trying to make a simple program to convert time given in seconds

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.