-
Hi,
The intristic Data control doesn't work with the newer data girds. I'd like to use the new ADO data control but I don't know how to hook it up to the grid.
How do I connect the ADO data grid to the grid?
Thanks
P.S. Originally the problem arose because I don't have a regular Grid control (DBGRID32.OCX) at home. I thought I had it before. Is it possible that when I installed VB6's Service Pack 4, it overwrote it with some newer grid? All I know is that I have the DBGRID32.OCX both at work (VB6 Ent) and at school (VB6 Pro) but it's missing at home.
-
simply click on the tab in the datasource property in DBGrid and you will have a dropdown list of your data controls on your form to choose from
-
yes, but how do I connect a database to the ADO Data control. With the regular 'intristic' Data control all I had to do was to set DatabaseName property. The new ADO Data control doesn't have a DatabaseName, so how can I select a database name?
-
Right click on the ADO control and click on the ADODC Properties. From the Property Pages you should be able to set up your connection to the database and table.
Back in your datagrid you can set your DataSource to the name of your ADO control. Then right click on the datagrid and retrieve fields to set up the columns.
Good luck !
-
To connect an ADO Data Control to a database you need to build a connection string. This is something new to ADO and the (old) data control was a tad simpler. Here's how to hook it up.
In the properties of the ADO Data control choose the field called custom. Open the ellipses (click on the three dots). A new window will open.
Select 'use a connection string' and then pick the button labeled 'build'. Select your database engine from the list that appears. For access 2000, use Jet 4.0 and for Access 97 and before use, Jet 3.51. Choose the 'next' button.
In the select or enter database field, choose the ellipses again and browse to your database file. Once you've chosen the 'open' button and are back at the screen with 'test connection' available, pick that button to test the database connection.
Chances are this worked, since I'm doing it as I write this :) Pick 'ok'. You should be back at the main screen and see the connection string now filled out.
Now, choose the recordsource tab. Under 'commandtype', you can choose the table name that you can intially open (or you can do this in code if you choose to later). If you did choose the table here, then below you in the next field you should now have a list of tables available to connect to.
Note: Once you're comfortable with all this you can do it all in code. The ADO data control is pretty programmable. I prefer using ADO code myself because I'm a control freak. But if you want something fast and it's a smallish project, the ADO control is hard to pass up.
Hope this helps.