Important alert: (current site time 7/16/2013 2:09:04 AM EDT)
 

VB icon

______________...:::SIJO Soft DSN:::...___

Email
Submitted on: 2/26/2003 7:19:16 AM
By: SIJO Soft Corp  
Level: Beginner
User Rating: By 3 Users
Compatibility: VB 5.0, VB 6.0, VB Script
Views: 12638
author picture
(About the author)
 
     Create / Delete DSN

 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :______________...:::SIJO Soft DSN:::...___
'**************************************
' **********************************************************************
' * Comments : Some functions for DSN
' *
' *
' **********************************************************************
Option Explicit
'Declarations Used to Generate DSN
Private Const ODBC_ADD_DSN = 1 ' Add data source
Private Const ODBC_CONFIG_DSN = 2' Configure (edit) data source
Private Const ODBC_REMOVE_DSN = 3' Remove data source
Private Const vbAPINull As Long = 0& ' NULL Pointer
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
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: ______________...:::SIJO Soft DSN:::...___
' Description:Create / Delete DSN
' By: SIJO Soft Corp
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=43561&lngWId=1'for details.'**************************************

Public Sub CreateDSN(sDSN As String)
 ' **********************************************************************
 ' * Comments : Create a DSN
 ' *
 ' *
 ' **********************************************************************
 Dim nRetAs Long
 Dim sDriverAs String
 Dim sAttributes As String
 sDriver = "Oracle73 Ver 2.5"
 sAttributes = "Server=pressdb.world" & Chr$(0)
 sAttributes = sAttributes & "DESCRIPTION=" & sDSN & Chr$(0)
 sAttributes = sAttributes & "DSN=" & sDSN & Chr$(0)
 sAttributes = sAttributes & "DATABASE=DB" & Chr$(0)
 sAttributes = sAttributes & "UID=Waty" & Chr$(0)
 sAttributes = sAttributes & "PWD=myPassword" & Chr$(0)
 DBEngine.RegisterDatabase "kiki", "Oracle73 Ver 2.5", True, sAttributes
 'nRet = SQLConfigDataSource(vbAPINull, ODBC_REMOVE_DSN, sDriver, sAttributes)
End Sub
Public Sub DeleteDSN(sDSN As String)
 ' #VBIDEUtils#************************************************************
 ' * Programmer Name : Waty Thierry
 ' * Web Site : www.geocities.com/ResearchTriangle/6311/
 ' * E-Mail : waty.thierry@usa.net
 ' * Date: 25/11/98
 ' * Time: 15:08
 ' * Module Name: DSN_Module
 ' * Module Filename : DSN.bas
 ' * Procedure Name : DeleteDSN
 ' * Parameters:
 ' * sDSN As String
 ' **********************************************************************
 ' * Comments : Delete a DSN
 ' *
 ' *
 ' **********************************************************************
 Dim nRetAs Long
 Dim sDriverAs String
 Dim sAttributes As String
 sDriver = "Oracle73 Ver 2.5"
 sAttributes = sAttributes & "DSN=" & sDSN & Chr$(0)
 nRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, sDriver, sAttributes)
End Sub


Other 13 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
6/14/2004 7:58:52 AMGulzar

this code is not working
There is error message Variable not declare and stop on the fowowng line

DBEngine.RegisterDatabase "kiki", "Oracle73 Ver 2.5", True, sAttributes

(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.