473,566 Members | 2,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Set Default Shipping Address

printedgoods
9 New Member
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 2864
jeffstl
432 Recognized Expert Contributor
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 Recognized Expert Specialist
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
printedgoods
9 New Member
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 defaultaddressR S 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
1457
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. Additional com objects will follow shortly to make using the UPS tools extremely easy for those programming in VB/ASP/ASP.NET or any language that lets you...
8
3950
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
5998
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, event though the tlog backup copy & restore process is working fine. When I look at the histories of both the backup and copy/restore jobs, they are...
4
2131
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
1702
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 even though the tran logs are being shipped and applied to the standby database on the backup server. 2) The log shipping monitor, when drilling...
2
4359
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 shipto info to the DHL web interface to print the 8 x 11 labels. We ship between 0 and 20 packages a day. If I get DHL pinfeed DHL shipping...
6
4613
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 priced by weight and doesn't matter about the number of packages, international shipping is by weight and package size, so we need to know the number...
3
6268
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 here if the shipping address is the same as the billling address"? I've looked everywhere for it but surprizingly have had no luck!
3
8500
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 Password:8pVQ6p5cHyQVuJJvrfosaBKqG Developer Test Key: vfNOPSmeA69gJFdf Test Account: 510087682 Test Meter: 1239156
0
7673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8109
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7645
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6263
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2085
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1202
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.