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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:54:27+00:00 2026-05-22T00:54:27+00:00

What I want to do is retrieve all emails from MS SQL Customer table

  • 0

What I want to do is retrieve all emails from MS SQL Customer table Email column and populate them in using JQuery autocomplete feature. The current system is using VB.NET 2.0.

What I have done is get all emails and put them in DataTable and loop through and put them in the string delimited by “,”. Put that string into hidden box. JQuery retrieve value from that hidden box and build an array using “array = emails.split(“,”);”. Here is the code.

It works pretty good on development server since we have only 2,000+ records but it is loading forever when I put that on the live server where there are 80,000+ records.

Front End

    <script type="text/javascript">
    $(function() {      
            var emails = $("#EmailList").val();
            var emailList = emails.split(",");

            $(".email-autocomplete").autocomplete({
                source: emailList
            });
        });

    </script>   
    <asp:TextBox class="email-autocomplete" ID="txtEmailAddress" 
runat="server" style="width:300px"></asp:TextBox>                                                                           
    <asp:HiddenField ID="EmailList" runat="server" />

Back End

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    FetchEmailList()

End Sub

Private Sub FetchEmailList()
        Dim dt As Data.DataTable = GetCustomers()
    Dim i As Integer
    Dim _emails As String

    For i = 0 To dt.Rows.Count()-1
    If IsDBNull(dt.Rows(i).Item("Email")) = False Then
       _emails &= dt.Rows(i).Item("Email") &  ","
    End If
    Next

    If _emails.length > 0 Then
        EmailList.Value = _emails.substring(0,_emails.length-1)
    End If

End Sub

I come up with two solutions –

  1. When I retrieve emails from database server, I will use function TableToStr and put all emails delimited by “,” in one field and VB.NET get that values and put it in hidden box. Here we can remove Looping through datatable in back end. However, JQuery still needs to “split” that string to build an array.

  2. Get emails from DB, build JSON and return it to JQuery.(I have done that in ASP.NET MVC3 with C# which is pretty easy using “return JSON” but need to do some researches how to do it in VB.NET 2.0).

What is the best practice to deal with autocomplete when our data source is quite large.

  • 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-05-22T00:54:28+00:00Added an answer on May 22, 2026 at 12:54 am

    First off, I would move your back end code to a generic HttpHandler (.ashx) file, then call that file from the jQuery autocomplete via AJAX. Also, caching the AJAX response will increase the performance.

    <script type="text/javascript>
    $(function() {
        var cache = {},
            lastXhr;
        $(".email-autocomplete").autocomplete({
            minLength: 2,
            source: function( request, response ) {
                var term = request.term;
                if ( term in cache ) {
                    response( cache[ term ] );
                    return;
                }
    
                lastXhr = $.getJSON( "getEmails.ashx", request, function( data, status, xhr ) {
                    cache[ term ] = data;
                    if ( xhr === lastXhr ) {
                        response( data );
                    }
                });
            }
        });
    });
    </script>
    

    *adapted from the jQuery UI demo

    The JSON response could be something as simple as:{ "emails" : ["email1@email.com", "email2@email.com", "email3@email.com"]}

    Also, your back end code should also use StringBuilder rather than ‘&=’. I have found string appends to be a huge performance hit.

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

Sidebar

Related Questions

I want to retrieve all records from one table when there are no matches
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
I'm using the following code to retrieve emails from my Gmail inbox. def get_mail
I am newbie to Address book programming. I want to retrieve all email id's
I want to retrieve all layers from a PSD file and get their name,
i want to retrieve all posts on a facebook page, but using the graph
I have a table called Review and i want to retrieve all review objects
I want to retrieve all case-insensitive duplicate entries from an array. Is this possible
I want to get emails from all folders from gmail. From inbox, sent and
I want to select and retrieve all the contents from an NSDictionary . I

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.