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
Code
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'"
AdoDc.Refresh
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
Hope this will help someone.... I sure would have appreciated it when I had problems.
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.