?
Solved

How to connect a MDB file thru DAO using only dsn

Posted on 2001-08-08
19
Medium Priority
?
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
  • 2
  • +3
19 Comments
 
LVL 43

Expert Comment

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



0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6363372
Hi venkat,

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

Author Comment

by:N_K_venkat
ID: 6363378


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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:N_K_venkat
ID: 6363421


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 100 total points
ID: 6363675
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
ID: 6363695
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
ID: 6363789
but how to use the DSN in the connection string.
open method of the connection object.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6363807
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
ID: 6363822
Dear TimCottee
  will it work for the database in the network also????
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6363837
Absolutely, the DSN specifies where the database is located.
0
 

Author Comment

by:N_K_venkat
ID: 6363862
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
ID: 6363898
ADO or DAO?
0
 

Author Comment

by:N_K_venkat
ID: 6363915
ADO only.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6363929
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
ID: 6366847
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
ID: 6366868
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
ID: 6366900
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
ID: 7006246
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
ID: 7103461
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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
Course of the Month9 days, 2 hours left to enroll

764 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