PC Review


Reply
Thread Tools Rate Thread

Create passthrough query using ADO

 
 
Steven K
Guest
Posts: n/a
 
      25th May 2004
Hello, I am trying to use the following code to create a passthrough query.
The code runs, but when I click on the query tab, the query is not there.
Based on the following code, I must be appending it to the procedures
object, but don't know what or where that is:
catPrice.Procedures.Append strQryName, cmdPrice

Any help with this would be appreciated.

--
Thanks in advance,

Steven



Sub CreatePassThroughQry()
Dim strDBPath As String, strSQL As String, strODBCConnect As String,
strQryName As String
Dim catPrice As New ADOX.Catalog
Dim cmdPrice As New ADODB.Command
Dim varProp As Variant

Dim strParm00 As String, strParm01 As String
Dim strParm02 As String, strParm03 As String, strParm04 As String

'Define parameters
strParm01 = "MyData"
strParm02 = Me.StartDate.Value
strParm03 = Me.EndDate.Value
strParm04 = ""
strParm00 = "'" & strParm01 & "', " & "'" & strParm02 & "'," & "'" &
strParm03 & "', " & "'" & strParm04 & "'"

' SQL statement.
strSQL = "exec sp_web_WinLoss " & strParm00

' Connection String
strODBCConnect =
"ODBC;DSN=MyDSN;DATABASE=MyDatabase;Trusted_Connection=Yes"

' Query Name
strQryName = "a_qsp_Test"

' Open the Catalog object.
catPrice.ActiveConnection = CurrentProject.Connection

' Set cmdPrice = New ADODB.Command
' Define SQL statement for query and set provider-specific properties for
query type and ODBC connection string.
With cmdPrice
.ActiveConnection = catPrice.ActiveConnection
.CommandText = strSQL
.Properties("Jet OLEDB:ODBC Pass-Through Statement") = True
.Properties("Jet OLEDB:Pass Through Query Connect String") =
strODBCConnect
End With

' Name and save query to Procedures collection.
catPrice.Procedures.Append strQryName, cmdPrice

Set catPrice = Nothing
End Sub


 
Reply With Quote
 
 
 
Reply

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Building/Storing a passthrough:How to assign connection string andmake passthrough Phil Smith Microsoft Access Queries 3 22nd Apr 2010 01:21 AM
Passthrough query Sandy Hayman Microsoft Access Queries 3 17th Mar 2009 01:48 PM
Passthrough Query Angel G Microsoft Access Form Coding 1 16th Oct 2007 01:26 PM
Passthrough Query SLOWS Access Query Editor Marc Microsoft Access 12 1st Aug 2006 03:49 AM
ADO or PassThrough Query daniel_mosneanu Microsoft Access VBA Modules 0 5th May 2006 12:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:16 AM.