krs_rama
asked on
How to Open the FILE dsn in vb6 coding ?
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 ?
what're the FILE dsns look like?
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
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
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ping..
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
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
sureshpodaralla...
Your solution is not correct for a
Your solution is not correct for a
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.
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.
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sCN As String
Screen.MousePointer = vbHourglass
sCN = "Provider=MSDASQL.1;Persis t Security & _
Info=False;Data Source=DSNFILE;Mode=ReadWr ite; & _
Initial Catalog=DATABASE"
Set cn = New ADODB.Connection
cn.ConnectionString = sCN
cn.Open
Here You Go I Hope This Helpsw
Have A Good Day!
Dim rs As ADODB.Recordset
Dim sCN As String
Screen.MousePointer = vbHourglass
sCN = "Provider=MSDASQL.1;Persis
Info=False;Data Source=DSNFILE;Mode=ReadWr
Initial Catalog=DATABASE"
Set cn = New ADODB.Connection
cn.ConnectionString = sCN
cn.Open
Here You Go I Hope This Helpsw
Have A Good Day!
I don't think that krs_rama is still listening....
ASKER
simple and good answer.. works out.. thanks !!! krs_rama