Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid Doubt

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi

Is it possible to connect an ACCESS Database to an ADO Control without an ODBC?

Thanks
 
Yes you can do that
Declare the following in your declarations;
dim cn As ADODB.Connection



On Error GoTo errhandler
Set cn = New ADODB.Connection
cn.ConnectionString = "Driver=Microsoft Access driver (*.mdb);DBQ=c:\Population Policy Database Integration\PopPolicyDataBase.mdb"

cn.CursorLocation = adUseClient
cn.Open

in the above code, after DBQ= place the path for your database
 
You can create an OLEDB connection using the ADO Data Control without writing one line of code. When you right-click the Data Control in design view you are prompted with a wizard that guides you through the connection process. When the wizard pops up click on the radio button Use Connection String and then click the Build button. Then you pick the Microsoft Access OLEDB Provider, then locate the Access DB you want to connect to. Then you pick your Record source, which can be a adCmdTable(Table recordset) or adCmdText(sql string). Then you should be good to go.

To reference a datagrid control to the ADO Control, in Form Load add this code DataGrid1.DataSource = adodc1.underlyingvalue

When you want to become more sophisticated in your programming you will not use the ADO control any longer, but will build your connection through code. Code offers more versatility.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top