Pass through query (1 Viewer)

p595659

Registered User.
Local time
Today, 19:13
Joined
Jul 5, 2006
Messages
30
Hi,
I'm trying to create a pass through query after looking at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/adocreateq.asp. I'm using Access 2000 trying to connect to a backend to retrieve the data.

Here's my code:
Code:
Sub CreatePassThroughQry(strDBPath As String, _
                         strSQL As String, _
                         strODBCConnect As String, _
                         strQryName As String)
   Dim catDB   As ADOX.Catalog
   Dim cmd     As ADODB.Command
   Dim varProp As Variant

   Set catDB = New ADOX.Catalog
   ' Open the Catalog object.
   catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=" & strDBPath

   Set cmd = New ADODB.Command
   ' Define SQL statement for query and set provider-specific
   ' properties for query type and ODBC connection string.
   With cmd
      .ActiveConnection = catDB.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.
   catDB.Procedures.Append strQryName, cmd

   Set catDB = Nothing


CreatePassThroughQry _
   "\\Server\DB.mdb", _
   "SELECT tblTurnover.newbusiness_ref AS REF, Sum(tblTurnover.turnover_value) AS [NETT ISSUED]" FROM tblTurnover GROUP BY tblTurnover.newbusiness_ref; ", _
"ODBC;DSN=DSNName;UID=xxxxxx;PWD=xxxx;", _
   "qry_ptNETTISS"

End Sub

What I need to know is how to use escape charecters so it skips double quotes?

Cheers,
Ben
 

Users who are viewing this thread

Top Bottom