Solved

Ado

Posted on 2001-06-27
4
330 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 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now