Solved

Erase System DSN

Posted on 2000-05-11
7
262 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free 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

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.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

752 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