Discussion Locked

Server Side vs. Client Side

0 helpful
11 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have 4 fields on an ASP page

City, State, Zip, County. When the user puts a value in the ZIP I need (in real time) to go out to my SQL database via ADO and grab the other 3 fields. The current list of zip codes is 80000 which is too large todownload all at once. How would I do this.

Thanks for any and all help.

11 replies

by roc180

Best way is to call a function after the user has entered the zip code. The code within the function would be something like:

Function GetInfo()

Set Conn= Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "Some Conn String"
Conn.Open 'Now you have Access to your DB

Set Rs=Server.createObject("ADODB.Recordset")
Rs.CursorLocation=adUseServer
Rs.Open "Select * From Tbl Where zip="& textfield &"",Conn,adOpenKeyset, adLockReadOnly

If Rs.Recordcount>0 then
City=Rs!City
State=Rs!State
County=Rs!County
End If

Rs.close
Set Rs=nothing
Conn.Close
Set Conn=nothing

End Function

by kbenedict

The answer to your problem is to use Microsoft Remote Scripting.

This allows you to create vb or javascript functions within ASP pages that can be called from client side scripts without reloading of the page.

Ideally you would like to retrieve all the data after they have keyed in the entire ZIP code.

You can download the Microsoft Remote Scripting components from http://msdn.microsoft.com/scripting/remotescripting/default.htm

Use their documentation for installing the files, for actual code samples to do the remote scripting, please refer to http://msdn.microsoft.com/workshop/server/asp/server042699.asp

This page contains a well documented sample that you could easily turn into the function you need, I could post the whole code here but I'm afraid it would exceed the size limit of these postings, if you would like a sample from me, please email kbenedict@workingworld.ca

Keith.

by cedric king

You could write a script to get the values that you want and set it to "RUNAT="SERVER"". The script will then run at the server instead of at the client. This should help.
But then when you say "real time", is it really so critical to get the information in real time? I mean if you are using ASP, you won't be downloading the 80000+ ZIP codes. All the ZIP codes will still reside at the server or rather the database, so it will be fine to Submit a Form to the web server to retrieve the data required.

by cratem

The fasted and logical way foe a Client Server application is to:

When the client get the ZIP code it will send the ZIP code to the server. You have to have server process that will get the other 3 data and pass it back to you. This is useful if you expect to have more han one client.

If only one client, just send a query via ODBC or ADO to the database and get the 3 data. It is quite simple though.

by gbworld

It really depends on the browser you are using. If this is an IE application, you can use the XML HTTP Request object to take the trip for you and not submit the form to the server. The XML can update the other fields. If this is not an option, but IE is, you can use DHTML with Remote Data Services (RDS).

If this is not IE-only, the easiest is to submit the form and repopulate, including the new values. There is a downside here for some downlevel browsers.

With that in mind, a form with just the zipcode that submits to the entire form might be just the ticket, as you do not have to "remember" a lot of values. I have seen this one employed in a variety of web apps.

GB

This discussion is closed to new replies.