Solved

Erase System DSN

Posted on 2000-05-11
7
269 Views
Last Modified: 2010-05-02
How can i delete a system SQL Server DSN
from ODBC in a vb function

      Option Explicit
Private Const ODBC_ADD_DSN = 1        ' Add data source
Private Const ODBC_CONFIG_DSN = 2
Private Const ODBC_REMOVE_DSN = 3     ' Private Const vbAPINull As Long =0&      ' NULL Pointer

      'Function Declare

          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

and the function

      Dim intRet As Long
      Dim strDriver As String
      Dim strAttributes As String
      strDriver = "SQL Server"
      strAttributes = "DSN=DSN_TEMP" & Chr$(0)
      intRet = SQLConfigDataSource(vbAPINull, ODBC_REMOVE_DSN, _
      strDriver, strAttributes)
      If intRet Then
          MsgBox "DSN Deleted"
      Else
          MsgBox "Delete Failed"
      End If
 
can you send me another example








 
0
Comment
Question by:BogdanGrama
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2803325
You could try to remove the registry settings directly, but your method is better.
Why do you ?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2803326
ask
0
 

Author Comment

by:BogdanGrama
ID: 2803374
To test a DSN connection on a netwoark
I have to create a dsn first
If a user of app is sett a rong server name The DSN remains
I whant to erase him from odbc whit a functiuon for example.

the code is from a VB4 Function

Do you have another ideea
The registre is good
I am a little bit scheptic: app is going to work on nt

whit pleasure
Bogdan Grama
Finsiel Romania
Bucharest
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 25 total points
ID: 2803391
You can find (add/edit/delete) registry entries for system DSN in:
HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI
This is true for Win9x, WinNT and Win2k

Hope this helps
0
 

Author Comment

by:BogdanGrama
ID: 2803405
OK Thanks
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2803458
HOWTO: Create and Remove a DSN in Visual Basic

http://support.microsoft.com/support/kb/articles/q171/1/46.asp?FR=0

0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2803472
sorry thats what you have posted already
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month6 days, 13 hours left to enroll

623 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