Search Tools Links Login

Adodc + dbGrid problem and MdacTyp discussions

I had problems using the datagrid attached to an ADOdc control.
Here is what I found.

Original Author: Eric Leduc


When using an ADOdc to connect to a Access database, where the command is set to adCmdUnknown to be able to set the recordSource using a SQL statement, and attach a datagrid to that control, if you attempt to add a new record to the empty list(corresponding to an empty table) you will get the error message 'current row unavailable'

This problem is not documented in Microsoft knowledgebase, or if I recall, the workaround they suggest does not work.

I found in some newsgroup that if you want to change the recordSource of the AdoDc , to avoid the problem with the grid, you first have to disconnect the grid from the Ado control

Set dataGrid.DataSource= Nothing

'then change the ado query

AdoDc.RecordSource = "SELECT * from myTable WHERE myField = 'someStringValueforExample'"


Set dataGrid.DataSource = AdoDc

if the table is empty, and you use the datagrid to add a new record, you will not get the current row error using this technique.

Other matters:

You will realize that in order to use the vb data wizard to create your startup data forms (wich is good), you will need to reference the msADO 2.7 Library

If you do so, to redistribute your application properly, you have to download the appropriate (2.7) MDAC_Type.exe from microsoft and put this file in the C:Program FilesMicrosoft Visual StudioVB98WizardsPDWizardRedist folder.

Hope this will help someone.... I sure would have appreciated it when I had problems.

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 129 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.