crystalReporterNew
Programmer
Hi,
I have been getting a System.NullReferenceException with the SQLConfigDataSource function. Can somebody please help?
The following is the code:
Public Declare Function SQLCreateDataSource Lib "odbccp32.dll" (ByVal hwnd&, ByVal lpszDS$) As Boolean
Public Declare Function SQLConfigDataSource Lib "odbccp32.dll" (ByVal hwnd As Long, ByVal fRequest As Integer, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Boolean
Private Const ODBC_ADD_DSN = 1&
Private Const ODBC_CONFIG_DSN = 2
Private Const ODBC_REMOVE_DSN = 3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim settings As String
Dim intret As Long
intret = SQLConfigDataSource(Me.Handle.ToInt64, ODBC_ADD_DSN, "MySQL ODBC 3.51 Driver", "DSN=AppliedEDSN\0""DESCRIPTION=Program\0""SERVER=192.168.1.105\0""ADDRESS=192.168.1.105\0""DATABASE=test\0""UID=root\0""PASSWORD=\0"
If intret Then
MessageBox.Show("DSN Added"
Else
MessageBox.Show("DSN Entry Failed"
End If
End Sub
I have been getting a System.NullReferenceException with the SQLConfigDataSource function. Can somebody please help?
The following is the code:
Public Declare Function SQLCreateDataSource Lib "odbccp32.dll" (ByVal hwnd&, ByVal lpszDS$) As Boolean
Public Declare Function SQLConfigDataSource Lib "odbccp32.dll" (ByVal hwnd As Long, ByVal fRequest As Integer, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Boolean
Private Const ODBC_ADD_DSN = 1&
Private Const ODBC_CONFIG_DSN = 2
Private Const ODBC_REMOVE_DSN = 3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim settings As String
Dim intret As Long
intret = SQLConfigDataSource(Me.Handle.ToInt64, ODBC_ADD_DSN, "MySQL ODBC 3.51 Driver", "DSN=AppliedEDSN\0""DESCRIPTION=Program\0""SERVER=192.168.1.105\0""ADDRESS=192.168.1.105\0""DATABASE=test\0""UID=root\0""PASSWORD=\0"
If intret Then
MessageBox.Show("DSN Added"
Else
MessageBox.Show("DSN Entry Failed"
End If
End Sub