|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
Try posting it so it is readable.
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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 |
|
#5
|
|||
|
|||
|
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. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Creating a store procedure |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|