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
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old May 6th, 2003, 04:11 PM
fergy fergy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 7 fergy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Using the IN Function with Stored procedure

I have the following ASP Code:

PHP Code:
if(MLS ""then MLS 0
if(MLS2 ""then MLS2 0
if(MLS3 ""then MLS3 0
if(MLS4 ""then MLS4 0
if(MLS5 ""then MLS5 0
if(MLS6 ""then MLS6 0


    
'---------------------------
    ' 
Database I/O
    dim oCon    
set oCon server.CreateObject("ADODB.Connection")    : oCon.Open(Application("WebConnectionString"))
    
dim SQL        SQL "EXEC proc_MLS @listingNumber='" MLS "','" MLS2 "','" MLS3 "','" MLS4 "','" MLS5 "','" MLS6 "'"
    
    
set rsListings oCon.execute(SQL


I have the following Stored Procedure:

PHP Code:
 CREATE PROCEDURE proc_MLS

    
@ListingNumber nvarchar(500)

    
AS


-- return 
result
select        
*
from        tblListings l
left join        tblPersonnel p1    on 
(l.ListingAgentID p1.PersonnelID)
left join        tblPersonnel p2    on (l.SecondAgentID p2.PersonnelID)
left join        tblCities    c    on (l.CityID c.CityID)
left join        tblCounties co    on (c.CountyID co.CountyID)
left join        tblStates s    on (co.StateID s.StateID)
where        ListingNumber IN(@ListingNumber)
and        
Active 


How do I make the multiple values get parsed correctly into the Stored procedure? I have tried the @ListingNumber= but i keep getting the Parameter Number 2 error and the @Name must come after the form. Any ideas from someone would be helpfull.

Reply With Quote
  #2  
Old May 12th, 2003, 09:59 AM
mrTed's Avatar
mrTed mrTed is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: a northern town
Posts: 74 mrTed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 49 sec
Reputation Power: 7
I would created a var for each 'MLS' and call the SP with 6 or whatever parameters. So just declare each value in the SP individually and then build it up in the IN() clause.

I can only assume that the command object thinks you are trying to pass multiple parameters when you are in fact only trying to pass one?

HTH.
__________________
/* measure twice, cut once */

Reply With Quote
  #3  
Old May 12th, 2003, 11:08 AM
fergy fergy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 7 fergy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Thanks

I am actually trying to pass up to 6 mls #'s at once. However i tried building the var's up with the in() but got the parameter 5 and parameter 2 warning from sql that says I cannot pass the @var= after i have already called the first one in the form? I'm guessing maybe create an array or something? Thanks for the help!

Reply With Quote
  #4  
Old May 12th, 2003, 11:20 AM
mrTed's Avatar
mrTed mrTed is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: a northern town
Posts: 74 mrTed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 49 sec
Reputation Power: 7
What I meant was create your SP to expect 6 parameters and pass the six parameters to it during the call.

PHP Code:
 CREATE PROCEDURE proc_MLS

    
@ListingNumber1 nvarchar(12),
    @
ListingNumber2 nvarchar(12),
    @
ListingNumber3 nvarchar(12),
    @
ListingNumber4 nvarchar(12),
    @
ListingNumber5 nvarchar(12),
    @
ListingNumber6 nvarchar(12),
    
AS

-- return 
result 


...and call it with somethng like...
PHP Code:
 SQL "EXEC proc_MLS('" MLS "','" MLS2 "','" MLS3 "','" MLS4 "','" MLS5 "','" MLS6 "')"
    
    
set rsListings oCon.execute(SQL


One thing to note that I just thought of is that you are assigning values to the var @listingnumber as you are passing it to the SP. I think this will not work. You need to assign the values to vars then pass them in order as my example.

HTH?

Reply With Quote
  #5  
Old May 12th, 2003, 11:35 AM
fergy fergy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 7 fergy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up Thanks for the help

Thanks for the help. That should work. Always good to get a new head thinking about it. Sometimes you get too bogged down on the problem that you miss the obvious.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Using the IN Function with Stored procedure


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 2 hosted by Hostway