Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Ado

Posted on 2001-06-27
4
Medium Priority
?
350 Views
Last Modified: 2013-11-23
I am tring to use ado object to execute a simple query on access database.

After I declared a connection varaiable I set the provider property to:

mConn.Provider = "Microsoft.Jet.OLEDB.4"

What should I write in

mConn.ConnectionString = ?

If the provider is Sql there is a way to create a file through the wizard open it by text editor and paste the
declaration , but I didn't see this possibility available when the provider is : Microsoft.Jet.OLEDB.4

Is there a way to create such a file ? If not what should be wriiten in the connection string ?


0
Comment
Question by:erezba
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 400 total points
ID: 6230499
erezba, here is a sample connectionstring for an access database:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb;Persist Security Info=False"

You can omit the provider part as you have already specified it in the provider property or you can do it all in the one assignment.
0
 
LVL 4

Expert Comment

by:WolfgangKoenig
ID: 6230518
Hi erezba!

Here is the code for etablish a connection to oledb:
DBFilePath stands for the location of the database file
(for example: C:\data\customers.mdb):
___________________________________________________________
 Set adoconn = New ADODB.Connection
 With adoconn
  .Provider = "Microsoft.Jet.OLEDB.4"
  .ConnectionString = "Data Source=" & DBFilePath
  .CursorLocation = adUseClient
  .Mode = adModeShareDenyNone
  .Open
 End With
0
 

Author Comment

by:erezba
ID: 6230947
I still wonder if there is a way of creating a file
like sql server, from which all depfinition could be pasted,
instead of coding it and remembering the right syntax.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6231032
HOWTO: Generate ODBC & OLEDB Connection Strings with Data Links
Last reviewed: November 17, 1998
Article ID: Q195913
 


--------------------------------------------------------------------------------

The information in this article applies to:
Microsoft Data Access Components version 2.0


SUMMARY
Microsoft Data Links, provided with the Microsoft Data Access Components 2.0, provide a convenient and standard way to create and validate the connection string syntax used with an ODBC Driver or OLE DB Provider. Even if you do not reference the data link in your application, when you use Data Links to create your connection string, it validates the connection string syntax to be used with your ODBC Driver or OLE DB Provider.



MORE INFORMATION
Data Links are available after installing Visual Basic 6.0, Data Access SDK 2.0, or MDAC 2.0 Run-time Components. You can access Data Links from the Visual Basic 6.0 Data Environment, or from the Microsoft Windows shell, as outlined in the following steps:



Steps to Build a Connection String

Install Visual Basic 6.0, the Data Access 2.0 SDK, or MDAC 2.0 Run-time Components.

Right-click on the Windows desktop, point to New, and select Microsoft Data Link to create a Microsoft Data Link shortcut on your desktop (New Microsoft Data Link.udl).

Right-click the New Microsoft Data Link and click Properties to open the Data Link Properties dialog box. To create a connection to a datasource, use the CONNECTION tab.
NOTE: You can optionally use the ADVANCED and ALL tabs to set specific behavior available to either an ODBC or OLE DB data source.


Once you have completed and tested your connection, click OK to save your new data link.

Open your New Microsoft Data Link.udl file with Notepad (or other text editor). From the .udl file, you can copy the connection string and use it in your application that connects to an MDAC technology.  

Is probably as good an answer to this as you need.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question