How to connect a MDB file thru DAO using only dsn

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.
N_K_venkatAsked:
Who is Participating?
 
loveneesh_bansalConnect With a Mentor Commented:
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
 
TimCotteeHead of Software ServicesCommented:
Set database = workspace.OpenDatabase ("DSN=MyDSNName", False, False)



0
 
Ryan ChongCommented:
Hi venkat,

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

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
N_K_venkatAuthor Commented:


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
 
N_K_venkatAuthor Commented:


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
 
withAtwistCommented:
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
 
N_K_venkatAuthor Commented:
but how to use the DSN in the connection string.
open method of the connection object.
0
 
TimCotteeHead of Software ServicesCommented:
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
 
N_K_venkatAuthor Commented:
Dear TimCottee
  will it work for the database in the network also????
0
 
TimCotteeHead of Software ServicesCommented:
Absolutely, the DSN specifies where the database is located.
0
 
N_K_venkatAuthor Commented:
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
 
TimCotteeHead of Software ServicesCommented:
ADO or DAO?
0
 
N_K_venkatAuthor Commented:
ADO only.
0
 
TimCotteeHead of Software ServicesCommented:
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
 
N_K_venkatAuthor Commented:
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
 
N_K_venkatAuthor Commented:
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
 
N_K_venkatAuthor Commented:
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
 
MoondancerCommented:
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
 
MoondancerCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.