BogdanGrama
asked on
Erase System DSN
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(vbAPIN ull, ODBC_REMOVE_DSN, _
strDriver, strAttributes)
If intRet Then
MsgBox "DSN Deleted"
Else
MsgBox "Delete Failed"
End If
can you send me another example
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(vbAPIN
strDriver, strAttributes)
If intRet Then
MsgBox "DSN Deleted"
Else
MsgBox "Delete Failed"
End If
can you send me another example
ask
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK Thanks
HOWTO: Create and Remove a DSN in Visual Basic
http://support.microsoft.com/support/kb/articles/q171/1/46.asp?FR=0
http://support.microsoft.com/support/kb/articles/q171/1/46.asp?FR=0
sorry thats what you have posted already
Why do you ?