|
-
Sep 5th, 2005, 06:25 PM
#1
Thread Starter
Frenzied Member
How to create an DSN?
Hi all,
How to create a DSN programmatically?
I need to create a system DSN in about 100 systems. So, If I create a program to do that it will be easier for me. So, pls help me to do that!
Thanks,
CS.
-
Sep 5th, 2005, 06:47 PM
#2
Re: How to create an DSN?
You don't actually need to use DSN's at all. You can connect to most (all?) databases by simply specifying the relevant information in a connection string.
This not only makes your "nightmare" installation easier, it also bypasses the problem of ODBC being removed in future (which is likely to happen, especially in 64bit Windows).
You may be able to find the details you need in the Connection Strings link below, if not give us more details
-
Sep 6th, 2005, 03:21 AM
#3
Hyperactive Member
Re: How to create an DSN?
i used this to create my DSN. then just called Connect on my main form. works fine for me. Its for an access database. think it will work well for others as well
VB Code:
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
Public DB As ADODB.Connection
Public connString As String
Public Sub Connect()
Call Create
connString = "DSN=VRRS;"
Set DB = New ADODB.Connection
DB.Open connString
End Sub
Private Function CreateAccessDSN(DSNName As String, DatabaseFullPath As String) As Boolean
Dim sAttributes As String
sAttributes = "DSN=" & DSNName & Chr(0)
sAttributes = sAttributes & "DBQ=" & DatabaseFullPath & Chr(0)
CreateAccessDSN = CreateDSN("Microsoft Access Driver (*.mdb)", sAttributes)
End Function
Private Function CreateDSN(Driver As String, Attributes As String) As Boolean
CreateDSN = SQLConfigDataSource(0&, 1, Driver, Attributes)
End Function
Private Sub Create()
Dim blnRetVal As Boolean
blnRetVal = CreateAccessDSN("VRRS", "C:\VRRS\VRRS.mdb")
End Sub
-
Sep 6th, 2005, 01:34 PM
#4
Thread Starter
Frenzied Member
Re: How to create an DSN?
Ok, fine! this is for Access. what about Oracle? Thanks a lot. CS.
-
Sep 6th, 2005, 02:04 PM
#5
Re: How to create an DSN?
Using one of these connection strings (instead of using a data source) should work for you, thus eliminating the need to set up a DSN as part of your installation:
"Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Username;Pwd=password;"
"Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=password;"
-
Jan 9th, 2006, 10:32 PM
#6
Thread Starter
Frenzied Member
Re: How to create an DSN?
I use ADO code to connect my access database. so, what is the connection string to eliminate the DSN?
-
Jan 9th, 2006, 10:46 PM
#7
Re: How to create an DSN?
Have you tried te suggestions in Post #5? You could also take a look at www.connectionstrings.com for guidance...
-
Jan 9th, 2006, 10:55 PM
#8
Thread Starter
Frenzied Member
Re: How to create an DSN?
-
Jan 9th, 2006, 10:59 PM
#9
Re: How to create an DSN?
No worries...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|