Solved

Erase System DSN

Posted on 2000-05-11
7
210 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]
Comment Utility
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]
Comment Utility
ask
0
 

Author Comment

by:BogdanGrama
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 25 total points
Comment Utility
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
Comment Utility
OK Thanks
0
 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
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
Comment Utility
sorry thats what you have posted already
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 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…

763 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

6 Experts available now in Live!

Get 1:1 Help Now