Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oddity with ADODC

Status
Not open for further replies.

AdaHacker

Programmer
Sep 6, 2001
392
US
I'm hoping someone can explain this to me. I'm retreiving data from an Access 97 database using an ADO data control in VB6. In this database, I have a table called "position" from which I'd like to get some records. The query I really want to run is:
SELECT position_number, group_number, title, type
FROM position LEFT JOIN groupnumbers
ON position.group_ID = groupnumbers.group_ID
I know there's nothing inherently wrong with the SQL, because I can copy and paste it into Access and the query runs as expected. However, when I do the Datacontrol.Refresh in my code, I get a message box with an OK button and no title reading:
[ADODC]: Unknown error. [ADO]:
When I push the button, this is immediately followed by the VB error:
Run-time error '-2147467259 (80004005)'
Method 'Refresh' of object IAdodc' failed

Now, the wierd thing is that if I use just the simple query
SELECT * FROM position
I get the same error. However, if I just change it to
SELECT * FROM [position]
then it works. It also works if I simply rename the table from "position" to "position1."

So the name "position" is obviously causing the problem. But why? I know "position" isn't a reserved word in SQL, so that can't be it. That just leaves ADO. Is there some arcane operation done on the string before passing it to the database which could use "position" as a reserved word? Where is this problem coming from?
 
The Position data member returns the current position of the cursor in the table, and according to MSDN, it applies to all table objects.

So whereas its not a reserved word, placing the square brackets [] around the word position dis-ambiguates the reference to table name, as opposed to the table object data member. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top