Create Paradox DSN in VB 
Author Message
 Create Paradox DSN in VB

Hello,

Is there someone who can help ?
I'm trying to create an User DSN in Windows using VB code.

But the create always fales ! I followed the instructions
I got from Microsoft

General Declarations
---------------------
'Constant Declaration
Public Const ODBC_ADD_DSN = 1        ' Add data source
Public Const ODBC_CONFIG_DSN = 2     ' Configure (edit)
data source
Public Const ODBC_REMOVE_DSN = 3     ' Remove data source
Public Const vbAPINull As Long = 0   ' NULL Pointer --

Quote:
>0&

'Function Declare
#If Win32 Then
    Public Declare Function SQLConfigDataSource
Lib "ODBCCP32.DLL" _
    (ByVal hwndParent As Long, ByVal fRequest As Long, _
    ByVal lpszDriver As String, ByVal lpszAttributes As
String) _
    As Long
#Else
    Public Declare Function SQLConfigDataSource
Lib "ODBCINST.DLL" _
   (ByVal hwndParent As Integer, ByVal fRequest As
Integer, ByVal _
   lpszDriver As String, ByVal lpszAttributes As String)
As Integer
#End If

Code behind command button
---------------------------

'DSN aanmaken
#If Win32 Then
          Dim intRet As Long
#Else
          Dim intRet As Integer
#End If
      Dim strDriver As String
      Dim strAttributes As String
      strDriver = "Microsoft Paradox Driver (*.db)"
      strAttributes = strAttributes & "PARADOXNETHPATH =
C:\Windows\System32" & Chr$(0)
      strAttributes = strAttributes & "DRIVERID = 538"
      strAttributes = strAttributes & "DEFAULTDIR =
C:\DATA" & Chr$(0)
      strAttributes = strAttributes & "DBQ = C:\DATA " &
Chr$(0)

      intRet = SQLConfigDataSource
(vbAPINull,ODBC_ADD_DSN,strDriver, strAttributes)
If intRet Then
          MsgBox "DSN Created", vbOKOnly
Else
          MsgBox "Create Failed", vbCritical
          Exit Sub
End If

Thanks in advance !
Bye



Tue, 04 Jan 2005 19:07:01 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Creating a DSN-less connection to Paradox

2. Crystal and ODBC DSN/DSN-less connections - do I need USER DSN or SYSTEM DSN

3. Creating a system dsn or file dsn

4. how to set paradox DSN?

5. Connecting to Paradox db without a DSN

6. Can you use VB to Create paradox Table?

7. Creating a system DSN with VB

8. Programmatically Create a DSN for SQL Server with VB

9. How can I create System DSN with VB ?

10. creating DSN from VB application

11. Creating a DSN via vb code

12. Creating a DSN via vb code

 

 
Powered by phpBB® Forum Software