CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: SQL

  1. #1
    Join Date
    May 1999
    Location
    South Africa
    Posts
    19

    SQL

    Hi All

    I am connecting to SQlServer using DAO.

    The following code selects all the records.

    Public Sub GetLists(Connect As tConnect)
    ' Returns any number of records.
    Set GetListsCursor = New tCursor
    Connect.RoutineName = "GetLists"
    Dim QD As QueryDef
    Set QD = Connect.DB.CreateQueryDef("", "Select NAME from Staff where Administrator = 'Y' UNION Select SHORTNAME FROM SECTORDETAILS WHERE ALPHANUMCODE NOT LIKE 'C%' AND ALPHANUMCODE NOT LIKE 'N%' UNION SELECT '#' +LISTNAME FROM USERSHARELIST WHERE UserID = " & TEmp_No & " UNION SELECT '*' +NAME FROM GROUPDETAILS ")
    Set GetListsCursor.Connect = Connect
    Set GetListsCursor.QD = QD
    Set GetListsCursor.RS = GetListsCursor.QD.OpenRecordset(dbOpenSnapshot, dbForwardOnly And dbReadOnly)
    End Sub

    It returns the following error:

    ?err.Description
    ODBC--call failed.
    ?err.Number
    3146

    I have no idea why.

    Thanx


  2. #2
    Join Date
    Sep 1999
    Posts
    17

    Re: SQL

    Doublecheck your connection string.

    Error 3146 means your not connected to the database.


  3. #3
    Guest

    Re: SQL

    Dim QD As QueryDef
    .
    .
    .
    Set GetListsCursor.QD = QD
    why dont you chance the name of the querydef from QD to other name.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured