Solved

How to connect a MDB file thru DAO using only dsn

Posted on 2001-08-08
19
334 Views
Last Modified: 2012-06-21
Dear Friends,
    Here i am having one Mdb file in my server.i want to interact with that database from my client thru DAO.
How to connect a MDB using dsn only and no file path.
Thanks in advance.
0
Comment
Question by:N_K_venkat
  • 9
  • 5
  • 2
  • +3
19 Comments
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
Set database = workspace.OpenDatabase ("DSN=MyDSNName", False, False)



0
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
Hi venkat,

Maybe this link make help too:
http://www.able-consulting.com/ado_conn.htm#ODBCDriverForAccess
0
 

Author Comment

by:N_K_venkat
Comment Utility


dear TimCottee,

how to make use of the workspace. it throws some errors
"OBJECT VARIABLE NOT SET". will this support for the database which is in the network???

0
 

Author Comment

by:N_K_venkat
Comment Utility


dear TimCottee,

how to make use of the workspace. it throws some errors
"OBJECT VARIABLE NOT SET". will this support for the database which is in the network???

0
 
LVL 1

Accepted Solution

by:
loveneesh_bansal earned 50 total points
Comment Utility
You can use the file dsn method or other wise make a dsn on the client side and configure that dsn by giving the path of the server. then call this dsn into your programm.

bye
0
 

Expert Comment

by:withAtwist
Comment Utility
N_K.  Tim wasn't very clear there.  

The error you are receiving is because you have to instatiate the workspace object first.  

Go to the VB Help and lookup "workspace" and also look up "opendatabase" using the Jet engine.

There are examples that are pretty clear on this subject.
0
 

Author Comment

by:N_K_venkat
Comment Utility
but how to use the DSN in the connection string.
open method of the connection object.
0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
Now that sounds much more like ADO than DAO, in ado all you do is:

Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
cnn.ConnectionString = "DSN=MyDSN;"
cnn.Open

For a fuller DAO example:


   Dim wrkJet As Workspace
   Dim dbsMyDB As Database

   ' Create Microsoft Jet Workspace object.
   Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)

   MsgBox "Opening Database..."
   Set dbsMyDB = wrkJet.OpenDatabase("DSN=MyDSN", False,False)
0
 

Author Comment

by:N_K_venkat
Comment Utility
Dear TimCottee
  will it work for the database in the network also????
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
Absolutely, the DSN specifies where the database is located.
0
 

Author Comment

by:N_K_venkat
Comment Utility
TimCottee,

boss really a beautiful code but how to use the recordset object to open a table.
will you pls help us on this.
0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
ADO or DAO?
0
 

Author Comment

by:N_K_venkat
Comment Utility
ADO only.
0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
ADO is easy:


Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
cnn.ConnectionString = "DSN=MyDSN;"
cnn.Open
rst.Open "MyTable",cnn,adOpenStatic,adLockOptimistic,adCmdTable
With rst
  .MoveFirst
  Do
    Msgbox .Fields("MyField").Value
    .MoveNext
  Loop Until .Eof
End With
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing

0
 

Author Comment

by:N_K_venkat
Comment Utility
Dear Friends,
   in the connection object open method is it possible to use the dsn name instead of using file path for the access database using ado.
0
 

Author Comment

by:N_K_venkat
Comment Utility
Dear Friends,
   in the connection object open method is it possible to use the dsn name instead of using file path for the access database using ado.
0
 

Author Comment

by:N_K_venkat
Comment Utility
Dear Friends,
   in the connection object open method is it possible to use the dsn name instead of using file path for the access database using ado.
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder or Mindphaser will return to finalize these if they are still open in 7 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20106428.html
http://www.experts-exchange.com/questions/Q.20162135.html
http://www.experts-exchange.com/questions/Q.20164399.html
http://www.experts-exchange.com/questions/Q.20165106.html
http://www.experts-exchange.com/questions/Q.20193420.html
http://www.experts-exchange.com/questions/Q.20262325.html
http://www.experts-exchange.com/questions/Q.20267916.html
http://www.experts-exchange.com/questions/Q.20281031.html
http://www.experts-exchange.com/questions/Q.20285275.html
http://www.experts-exchange.com/questions/Q.20291239.html
http://www.experts-exchange.com/questions/Q.20292191.html
http://www.experts-exchange.com/questions/Q.20292203.html



*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
 
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Thanks for returning and finalizing these questions, however all that I've viewed are "C" grades and no comments from you as to why.  Can you please tell us?  If this was graded in error, I can correct this for you.

More about grading here:
http://www.experts-exchange.com/new_users/Q_20310437.html

Moondancer - EE Moderator
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

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

16 Experts available now in Live!

Get 1:1 Help Now