Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create DSN at Install

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
Can anyone point me in the right direction to create a DSN so it installs when the program installs using the Package and Deployment Wizard. Or any other Install Program for that matter that will compile VB Code. I'm using VB6.0

I've searched the web over and the FAQ's on this and other sites. I find plenty of ways to do it at the Programs RunTime, but not at the time of the Install.

I like to use DSN's because it's easier to network a Program using them. Eventually, I'd like to be able to ask the user at the time of Install what their Network Drive is so it will set up correctly on their machine. I'll worry about that later though.

Rob
Just my $.02.
 
What database are you using the DSN for? It's much easier to use DSN-less connections if you're using ADO.

The only way I know to install a DSN is through a registry script, assuming the driver is already on the user's machine.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
If you are a bit concerned about security, note that system DSNs have the password stored in plaintext. So you may decide to give the password separately. If you do that, using an on-the-fly connection string is much easier.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Thanks guys. I'm using Access 2000 for the Database. The driver is on all of the computers that it will be used on though.

I created a DSN for it because it's easier IMHO to network a program using DSN's. I may be wrong about that though.

I've never heard of a UDL, but I Googled it and I'm going to look into it more.

I really don't want an "on the fly" connection because I don't think it would be networkable, but I may be wrong about that too.

Thanks for giving me the options guys. I appreciate it.
RT

Rob
Just my $.02.
 
DSNs are just systemwide global variables and therefore a real pain. We have some office applications that require them, and I cannot use the program if I do some maintenance on it, although it is perfectly possible to have two instances open.

There is nothing you can do with a system DSN that you cannot do "on the fly". see for examples for all kinds of databases. A system DSN is just a way to store a connection string on the machine.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Thanks Don. I'll give it a try.

Rob
Just my $.02.
 
A while ago I had to do something similar for an ODBC text driver DSN. Maybe this code will help you get started.

Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
(ByVal hwndparent As Long, ByVal frequest As Long, _
ByVal lpszdriver As String, ByVal lpszattributes As String) _
As Long

Sub Main()

Dim intret As Long
Dim atts As String
Dim strdriver As String

strdriver = "Microsoft Text Driver (*.txt; *.csv)"
atts = "DSN=" & "Text Files"
intret = SQLConfigDataSource(0, 1, strdriver, atts)

If intret Then
Msgbox("DSN created sucessfully")
Else
MsgBox ("There was a problem setting up the DSN, please contact support")
End If

End Sub


In order to understand recursion, you must first understand recursion.
 
Thanks taupirho, I'll look into that.

Rob
Just my $.02.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top