ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old June 10th, 2003, 02:09 PM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 4 m 10 sec
Reputation Power: 75
posting to 2 db's

I have a service request form in asp, which takes a bunch of data (name, id, etc). it then has 2 checkboxes, either or both of which can be checked to request a certain service. depending on which box is checked, the other data collected is inserted into a corresponding database. what is the best way to do this?
can i just use 2 IF statements (not nested) to open the connections to the databases?

Reply With Quote
  #2  
Old June 11th, 2003, 09:11 PM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
IF statements would be the easiest.
You'd probably need three statements though,
1 for checkbox1 checked
1 for checkbox2 checked
1 for both checked
__________________
How can I soar like an eagle when
I'm flying with turkey's?

Reply With Quote
  #3  
Old June 12th, 2003, 02:41 AM
spincycler spincycler is offline
&nbsp;
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Brisbane
Posts: 15 spincycler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'd use an if statement to test the values and then do some stuff based on the value...

Code:

<%
' grab all your form values...
	myFormValue1 = request.form("FormValue1")
	myFormValue2 = request.form("FormValue2")

	checkbox1Value = request.form("checkbox1")
	checkbox2Value = request.form("checkbox2")

'build your SQL satetement...
	SQL1 = "some sql statement based on what you want to do if checkbox1Value = true"
	SQL2 = "some sql statement based on what you want to do if checkbox2Value = true"

'conditionally execute your SQL statement...
	if checkbox1Value = "checked" then
		'open data base connection #1 and do your stuff..
			set cn1 = server.createObject("adodb.connection")
			cn1.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\yourDatabase1.mdb")
		execute SQL1
	elseif checkbox2Value = "checked" then
		'open data base connection #2 and do your stuff..
		set cn2 = server.createObject("adodb.connection")
			cn2.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\yourDatabase2.mdb")
		execute SQL1
	end if
%>




Hope this helps,
Jb.

Reply With Quote
  #4  
Old June 12th, 2003, 07:59 AM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 4 m 10 sec
Reputation Power: 75
it looks promising, but what is the value of the
("FormValue1") and ("FormValue2") parts? that is, what do i put in there, and why?

Reply With Quote
  #5  
Old June 12th, 2003, 08:18 AM
spincycler spincycler is offline
&nbsp;
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Brisbane
Posts: 15 spincycler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Tell me if you've heard this one before ...
I handle forms by separating the 'form display' scripts from the 'form processing' scripts,
that is, I display the form using one file (let's call it "index.asp") and I use a different
file to handle the form processing (let's call it "act_index.asp").

In index.asp I'd have something like this...

Code:
<form action="act_index.asp" method="post">	
	Name: <input type="text" name="FormValue1" maxlength="40"><br>
	ID :  <input type="text" name="FormValue2" maxlength="40"><br>
	Which service do you want?<br>
	<input type="checkbox" name="checkbox1" value="checked"> Service A<br>
	<input type="checkbox" name="checkbox2" value="checked"> Service B<br>
	<input type="submit" name="submit" value="submit request">
</form>


then in the act_index.asp file I'd have the form processing stuff...

Code:
<%
' grab all your form values...
	myFormValue1 = request.form("FormValue1")
	myFormValue2 = request.form("FormValue2")

	checkbox1Value = request.form("checkbox1")
	checkbox2Value = request.form("checkbox2")

'build your SQL satetement...
	SQL1 = "some sql statement based on what you want to do if checkbox1Value = true"
	SQL2 = "some sql statement based on what you want to do if checkbox2Value = true"

'conditionally execute your SQL statement...
	if checkbox1Value = "checked" then
		'open data base connection #1 and do your stuff..
			set cn1 = server.createObject("adodb.connection")
			cn1.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\yourDatabase1.mdb")
		execute SQL1
	elseif checkbox2Value = "checked" then
		'open data base connection #2 and do your stuff..
		set cn2 = server.createObject("adodb.connection")
			cn2.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\yourDatabase2.mdb")
		execute SQL2
	end if
%>

Reply With Quote
  #6  
Old June 12th, 2003, 08:21 AM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 4 m 10 sec
Reputation Power: 75
ah, i do it the same way. just didn't quite put 2 & 2 together there. i was too focused on just the checkbox part. thanks for clarifying

Reply With Quote
  #7  
Old June 12th, 2003, 08:33 AM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 4 m 10 sec
Reputation Power: 75
Thanks

thanks a bunch spincycler. your comments to this question and my related "if" statement question really helped me figure this out and solve my problem

Reply With Quote
  #8  
Old June 12th, 2003, 08:38 AM
spincycler spincycler is offline
&nbsp;
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Brisbane
Posts: 15 spincycler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
just looking at my code I think I see a bug..
you may need to have two separate 'if' statements.

(without testing the code)

I think the way elseif's work is, if the first expression returns 'true' then the second expression will never be evaluated.

Iteration #2:
Code:
if checkbox1Value = "checked" then
		'open data base connection #1 and do your stuff..
			set cn1 = server.createObject("adodb.connection")
			cn1.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\yourDatabase1.mdb")
		execute SQL1
	end if
	if checkbox2Value = "checked" then
		'open data base connection #2 and do your stuff..
		set cn2 = server.createObject("adodb.connection")
			cn2.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\yourDatabase2.mdb")
		execute SQL2
	end if

Reply With Quote
  #9  
Old June 12th, 2003, 08:50 AM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 4 m 10 sec
Reputation Power: 75
that was indeed the case. 2 if statements were needed.

Reply With Quote
  #10  
Old June 12th, 2003, 08:56 AM
spincycler spincycler is offline
&nbsp;
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Brisbane
Posts: 15 spincycler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
as you rightly pointed out in your anser to my
array/checkbox question..

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > posting to 2 db's


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway