Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

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 ASP Free Forums Sponsor:
  #1  
Old March 10th, 2005, 10:15 AM
samcneal samcneal is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 75 samcneal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 26 m 2 sec
Reputation Power: 4
Creating a store procedure

Is there a way to have a SQL Store Procedure to do what this VB code is doing?



Example

The following example uses the CDO Person object to search for candidates who live in California.

Visual Basic

'////////////////////////////////////////////////////////////////////////////////////////////////////'//Function: SearchContacts'//Purpose: Searches through the contacts folder of a specified mail-directory for candidates who'// live in California.'//Input/Output:'// strWhereClause = Contains the Where clause of the SQL search string.'// iMbx = the Mailbox which contains the contacts folder to be searched.'// Conn = the active ADODB Connection object for the contacts folder to be searched.'//Notes:'////////////////////////////////////////////////////////////////////////////////////////////////////' Note: It is recommended that all input parameters be validated when they are' first obtained from the user or user interface.Function SearchContacts( strWhereClause as String, iMbx as CDO.IMailbox, Conn as ADODB.Connection ) Dim Rs as New ADODB.Recordset Set Rs.ActiveConnection = Conn strSQL = "select ""DAV:href"", " & _ """urn:schemas:contacts:fileas"", " & _ """urn:schemas:contacts:email1""" & _ "from " strSQL = strSQL & """" & iMbx.Contacts & """ " strSQL = strSQL & strWhereClause Rs.Open strSQL, ConnEnd Function

Reply With Quote
  #2  
Old March 10th, 2005, 10:44 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
Try posting it so it is readable.

Reply With Quote
  #3  
Old March 10th, 2005, 10:46 AM
samcneal samcneal is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 75 samcneal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 26 m 2 sec
Reputation Power: 4
Sorry.

Function SearchContacts( strWhereClause as String, iMbx as CDO.IMailbox, Conn as ADODB.Connection )

Dim Rs as New ADODB.Recordset
Set Rs.ActiveConnection = Conn
strSQL = "select ""DAV:href"", " & _
"""urn:schemas:contacts:fileas"", " & _
"""urn:schemas:contacts:email1""" & _
"from "
strSQL = strSQL & """" & iMbx.Contacts & """ "
strSQL = strSQL & strWhereClause
Rs.Open strSQL, Conn
End Function

Reply With Quote
  #4  
Old March 10th, 2005, 10:50 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
Try something like this, although it depends on your code, because that looks more like a dynamic sql statement.
Code:
CREATE PROCEDURE stp_SearchContacts
   @FileAs As varchar(20),
   @Email As varchar(20)
AS
SELECT *
FROM Contacts 
WHERE FileAs = @FileAs
AND Email = @Email

Reply With Quote
  #5  
Old March 10th, 2005, 11:04 AM
samcneal samcneal is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 75 samcneal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 26 m 2 sec
Reputation Power: 4
Yes,

Well I was trying to duplicate this code to search users' mailbox contact folders to extract email addresses to build a distribution list.

The VB code would work but I'm not a programmer and I don't have Visual Studio to test it out, so I was hoping that I could get the expected same results from SQL.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Creating a store 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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT