Solved

Adding an ODBC connection

Posted on 2006-06-15
6
227 Views
Last Modified: 2010-04-07
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
0
Comment
Question by:posae
  • 3
  • 3
6 Comments
 

Author Comment

by:posae
Comment Utility
Oh Yea...the app is in VB6
0
 
LVL 18

Accepted Solution

by:
mirtheil earned 500 total points
Comment Utility
You can use SQLConfigDataSource ODBC API call.  Here's a link that shows how to do it for Access but can be modified for other databases:
http://support.microsoft.com/?kbid=231156
0
 

Author Comment

by:posae
Comment Utility
thanks mirtheil...what attributes do I have to include?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 18

Expert Comment

by:mirtheil
Comment Utility
It depends on the DBMS you are using.  You'll basically include all of the keyword pairs that make up a DSN.  
0
 

Author Comment

by:posae
Comment Utility
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


0
 
LVL 18

Expert Comment

by:mirtheil
Comment Utility
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

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now