Link to home
Start Free TrialLog in
Avatar of posae
posae

asked on

Adding an ODBC connection

Hello,

I have a toolbar that needs to do some SQL Database lookups from 50 user desktops.  I need to create an ODBC connection for each the first time the user needs to use it.

The toolbar starts at startup and needs to check to see if the ODBC connection is there
If not, i need to create it as a system ODBC connection

I have tried to add the keys using group policy but it is not working for some reason.

Any help is greatly appreciated!!!! ----  URGENT!

Eric
Avatar of posae
posae

ASKER

Oh Yea...the app is in VB6
ASKER CERTIFIED SOLUTION
Avatar of Mirtheil
Mirtheil
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of posae

ASKER

thanks mirtheil...what attributes do I have to include?
It depends on the DBMS you are using.  You'll basically include all of the keyword pairs that make up a DSN.  
Avatar of posae

ASKER

This is what I have in the code and it keeps erroring out...any ideas?

Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (ByVal hwndParent As Long, ByVal fRequest As Long, ByVallpszDriver As String, ByVal lpszAttributes As String) As Long

Private Function Build_SystemDSN()
Dim ReturnValue As Integer
Dim Driver As String
Dim Attributes As String


   Driver = "SQL Server" & Chr(0)
   Attributes = "SERVER=samcoapps" & Chr(0)
   Attributes = Attributes & "DESCRIPTION=New DSN" & Chr(0)
   Attributes = Attributes & "DSN=DSN_TEMP" & Chr(0)
   Attributes = Attributes & "DATABASE=CRM" & Chr(0)
   
   ret = SQLConfigDataSource(0, 4, Driver, Attributes)
   
   'ret is equal to 1 on success and 0 if there is an error
   If ret <> 1 Then
       MsgBox "DSN Creation Failed"
   End If

End Function


Here's a link to some code.  I haven't worked with SQL Server.  THe code below did create the DSN for me (but I can't test the DSN since I don't have SQL Server installed)
http://www.freevbcode.com/ShowCode.Asp?ID=502