Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 28th, 2005, 11:14 AM
Authorized User
 
Join Date: Aug 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query

Hello, when I type this query into the query editor, it works fine, but when I use VBA to run this query, it gives me no results.

Query:
Code:
SELECT COUNTY.PK_COUNTY, COUNTY.COUNTY_NAME FROM DESIGN_EXCEPTION INNER JOIN (COUNTY INNER JOIN EXCEPTION_COUNTY_CONNECTOR ON COUNTY.PK_COUNTY = EXCEPTION_COUNTY_CONNECTOR.FK_COUNTY) ON DESIGN_EXCEPTION.PK_DESIGN_EXCEPTION = EXCEPTION_COUNTY_CONNECTOR.FK_DESIGN_EXCEPTION WHERE EXCEPTION_COUNTY_CONNECTOR.FK_DESIGN_EXCEPTION= 149 AND DESIGN_EXCEPTION.PRIMARY_DISTRICT=10 AND COUNTY.FK_DISTRICT = 10;

Function i use to run the query

Code:
Public Function GetRecords(ByVal strSQL As String, ByRef rstRecordSet As ADODB.Recordset, Optional ByRef actionSQL As Variant = "") As Boolean


    If (actionSQL <> "") Then

        Dim cmdCommand As New ADODB.Command

    End If



    Dim rstCommand As New ADODB.Command

    If (actionSQL <> "") Then


        MainConnection.Execute actionSQL, dbFailOnError


        With cmdCommand
            .ActiveConnection = MainConnection
            .CommandText = actionSQL
            .CommandType = adCmdText
        End With
    End If

  'Defines our command object


  With rstCommand
    .ActiveConnection = MainConnection
    .CommandText = strSQL
    .CommandType = adCmdText

  End With



  With rstRecordSet
    .CursorType = adOpenStatic
    .CursorLocation = adUseClient
    .LockType = adLockOptimistic
    .Open rstCommand
  End With



    If (actionSQL <> "") Then
        Set cmdCommand = Nothing
     End If
    Set rstCommand = Nothing


End Function
ÐaÐeVi£
__________________
ÐaÐeVi£





Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
how to make a query from an existing query raport SQL Language 3 November 13th, 2006 08:59 PM
I solved insert query.now see this Update Query. [email protected] VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Syntax error in query. Incomplete query clause. dispickle ADO.NET 3 April 16th, 2004 01:04 PM
Error on Make-Table Query In Union Query rylemer Access 1 August 20th, 2003 07:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.