Solved

Ado

Posted on 2001-06-27
4
340 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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

839 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