Solved

Erase System DSN

Posted on 2000-05-11
7
238 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 142

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 142

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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 142

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 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