|
-
September 22nd, 1999, 07:15 AM
#1
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
-
September 27th, 1999, 02:46 AM
#2
Re: SQL
Doublecheck your connection string.
Error 3146 means your not connected to the database.
-
September 27th, 1999, 08:40 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|