VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Adodc + dbGrid problem and MdacTyp discussions

by Eric Leduc (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

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

Rate Adodc + dbGrid problem and MdacTyp discussions

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  C:\Program Files\Microsoft Visual Studio\VB98\Wizards\PDWizard\Redist  folder.


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

Download this snippet    Add to My Saved Code

Adodc + dbGrid problem and MdacTyp discussions Comments

No comments have been posted about Adodc + dbGrid problem and MdacTyp discussions. Why not be the first to post a comment about Adodc + dbGrid problem and MdacTyp discussions.

Post your comment

Subject:
Message:
0/1000 characters