Advertisement
ASP_Volume2 Databases/ Data Access/ DAO/ ADO #26873

Adodc + dbGrid problem and MdacTyp discussions

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

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
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' <BR><BR>
This problem is not documented in Microsoft knowledgebase, or if I recall, the workaround they suggest does not work. <BR><BR>
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 <BR><code>
Set dataGrid.DataSource= Nothing<BR>
'then change the ado query<BR>
AdoDc.RecordSource = "SELECT * from myTable WHERE myField = 'someStringValueforExample'"<BR>
AdoDc.Refresh<BR>
Set dataGrid.DataSource = AdoDc </code><BR><BR>
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. <BR><BR>
Other matters:<BR>
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 <BR><BR>
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 <BOLD> C:\Program Files\Microsoft Visual Studio\VB98\Wizards\PDWizard\Redist </BOLD> folder.<BR><BR>
Hope this will help someone.... I sure would have appreciated it when I had problems.
Original Comments (3)
Recovered from Wayback Machine