473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Set Default Shipping Address

printedgoods
Hello All!

I have a shipping profile page that i created and works perfectly. User can create multiple shipping addresses that post to an access DB and they can then edit them (1 at a time). I have all the appropriate java validators in place for the submit (that took about 300 lines of code :) ). I have it to where the user can only have one default address as well.

The question that i have relates to auto entering a default shipping address.

If one is not selected in the database i would like to loop throught the recordset and select the top 1. If the user deletes the default address i want to select the top 1. If one already exists then i want keep that one selected.

I have been working on this for a while and have put it aside so i could reset my thoughts.


Thanks for any help

Jason
Printedgoods
May 28 '08 #1
3 2856
jeffstl
432 Expert 256MB
You don't need to loop through a recordset to get your top record. You can just use a quick SQL query to return a record set with only 1 record in it. (the top record) using the TOP syntax.

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT TOP 1 * FROM ShippingAddresses
  3.  
  4.  
May 28 '08 #2
jhardman
3,406 Expert 2GB
Jeff's right, and this is the fastest method. However if you don't remember the "Top 1" method and just say "SELECT *" you will get the top one if you don't loop.

Jared
Jun 5 '08 #3
I got it all figured out. It just took moving on to another page and coming back.

Here is what i did though I ran the defaultaddressRS to get the address info then:

Expand|Select|Wrap|Line Numbers
  1.  
  2. If defaultaddressRS.EOF Then
  3. defaultaddressRS.close
  4. set insertdefaultaddressRS = Server.CreateObject("ADODB.RecordSet")
  5. insertdefaultaddressQuery = "Select top 1 id from customer_addresses_shipping where customer_id = " & Request.Cookies("cur_account") 
  6. insertdefaultaddressRS.Open insertdefaultaddressQuery, dbConn, adOpenStatic, adLockReadOnly, adCmdText
  7.  
  8. udefault = (insertdefaultaddressRS.fields("id"))
  9.  
  10. set udefaultRS = Server.CreateObject("ADODB.RecordSet")
  11. udefaultQuery = "update customer_addresses_shipping set default = 'on' where id = " & udefault
  12. udefaultRS.Open udefaultQuery, dbConn, adOpenStatic, adLockReadOnly, adCmdText
  13.  
  14. Else
  15. defaultaddressRS.close    
  16. End If
  17.  

This worked like a charm and so far no broken page.

Thanks
Jason
Jun 5 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jon Glazer | last post by:
I am about to release a beta version of a com object for retrieving UPS shipping rates directly from UPS.COM. I am looking for a few interested parties to try it out and give me feedback. ...
8
by: Gabriel Cooper | last post by:
I've made UPS and FedEx shipping rate request modules in python using XML. Is there an interest in putting this on the web?
2
by: Tim Groulx | last post by:
Hello, I am setting up log shipping between two SQL servers. Everything in the setup seems to work fine. The problem I am having is that the "Log Shipping Alert Job - Backup" job is failing,...
4
by: Jason Huang | last post by:
Hi, In the MS SQL 2000 Server, if the log shipping is set up right, does that mean data in primary server changed will mapped to secondary server later on? Thanks. Jason
0
by: InProcess | last post by:
We have successfully implemented Log Shipping between two MS SQL Server 2000 servers (bothe SP3). The problem we are having is two fold: 1) The tran log on the primary server is not being truncated...
2
by: Fred | last post by:
Hi. Sorry, but I don't know where else to ask. I wrote a access shipping database and we currently use the web interface for DHL to print shipping labels. That means we have to manualy transpose...
6
by: Chris Buckett | last post by:
Hi, I was just wondering if anyone has had any experience in developing a shipping matrix. We are based in the UK, and we need to ship both locally and internationally. Local shipping is...
3
by: libsfan01 | last post by:
Hi all! Can anyone show me how to use javascript to populate shipping address form fields with pre-typed payment address details upon checking of a checkbox next to the obligatory text "click...
3
by: supperham | last post by:
hi: can sone one tell me how to use fedex web service in php to calculate shipping fee? i already have fedex account and 4 keys used to test application Test...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.