Solved

How to Open the FILE dsn in vb6 coding ?

Posted on 2001-06-14
11
991 Views
Last Modified: 2012-05-04
I have created two FILE dsn one for Mdb and the other for dbf (Ms-Vfp). I am unable to access the database or dbf specified thru the created dsn. I want to open the Data files attached with the above dsns thru coding.If i copy the FILE dsns in some other remote machine will it work ?
0
Comment
Question by:krs_rama
[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
11 Comments
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6194168
what're the FILE dsns look like?
0
 

Expert Comment

by:mpaul4u
ID: 6194287
hi,
FILE DSN  WORKS IF COPIED TO REMOTE machines.
create dns same way as other dsns.from control panel
32 bit odbc setting give a name to the file dsn locate database and server and even we have option to test it.
then specify the file dsn name in code to open connection.
it works if tested at the odbc settings.

regards
Martin
0
 
LVL 3

Expert Comment

by:nigelrowe
ID: 6194340
I don't know if this what you're looking for but here goes...

You can export the Windows registry values for all of the DSN's on your machine to a .REG file. You can then merge this file into the registry of another machine. However, be aware that the driver filepath for each entry is included in this file, so you have to edit this file, before merging, to be sure that it reflects the filepath on the other machine.

To do this, run regedit, search for ODBC (Match whole string only). When it is found, click on registry, click on export registry file and follow the instructions which follow.

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!

 
LVL 4

Accepted Solution

by:
mcoop earned 50 total points
ID: 6194435

I've used this succesfully with a pre-existing fileDSN...

dim cn As ADODB.connection
cn.open "fileDSN=myDSNname"

etc
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6194517
ping..
0
 

Expert Comment

by:sureshpodaralla
ID: 6199393
Set cnn = New ADODB.Connection
cnn.Open "DSN=" & sOraDsn & ";UID=" & sUser & ";PWD=" & sPassWord

Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient


rst.Open "Select * from Table1 where Col1= " & strFiled1, cnn, adOpenStatic, adLockOptimistic

I hope this will help you.

Thanks,
Suresh Podaralla
0
 
LVL 4

Expert Comment

by:mcoop
ID: 6199451
sureshpodaralla...

Your solution is not correct for a
0
 
LVL 4

Expert Comment

by:mcoop
ID: 6199452
Oops... !

sureshpodaralla , your code is not correct for a fileDSN as requested.  The DSN= parameter is for 'machine' DSN's

(I've tried it before, and only found the fileDSN= pram by good fortune !)

Cheers

You are correct though... if the fileDSN doesn't have the UID= and PWD= params filled in, then you do need to pass them in the .Open function.

BTW: to answer the second part of the original question,
DSN's are stored in \Program Files\COmmon Files\ODBC\Data Sources.  You can open and edit them with a text editor, or use a wizard (eg in Access) to manipulate them.



0
 

Expert Comment

by:VBSysCOM1
ID: 6207868
   Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim sCN As String
    Screen.MousePointer = vbHourglass
    sCN = "Provider=MSDASQL.1;Persist Security & _  
    Info=False;Data Source=DSNFILE;Mode=ReadWrite; & _
    Initial Catalog=DATABASE"
    Set cn = New ADODB.Connection
    cn.ConnectionString = sCN
    cn.Open


Here You Go I Hope This Helpsw


Have A Good Day!
0
 
LVL 4

Expert Comment

by:mcoop
ID: 6208374


I don't think that krs_rama is still listening....
0
 

Author Comment

by:krs_rama
ID: 6248258
simple and good answer.. works out.. thanks !!! krs_rama
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bit defender blocks good applications 2 107
Spell Check in VB6 13 137
MS SQL Update query with connected table data 3 63
adding "ungroup sheets" to existing vbs code 5 57
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 …
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 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