Hello,
This is my vb.net code =>
Imports System.Math
Imports MySql.Data.MySqlClient
Imports System.Data.ODBC
Public Class Form1
Inherits System.Windows.Forms.Form
Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Integer) As Integer
Private Declare Sub CloseDevice Lib "k8055d.dll" ()
Private Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer) As Integer
Private Declare Sub ReadAllAnalog Lib "k8055d.dll" (ByRef Data1 As Integer, ByRef Data2 As Integer)
Private Declare Sub OutputAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer, ByVal Data As Integer)
Private Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Integer, ByVal Data2 As Integer)
Private Declare Sub ClearAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer)
Private Declare Sub SetAllAnalog Lib "k8055d.dll" ()
Private Declare Sub ClearAllAnalog Lib "k8055d.dll" ()
Private Declare Sub SetAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer)
Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Integer)
Private Declare Sub ClearDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)
Private Declare Sub ClearAllDigital Lib "k8055d.dll" ()
Private Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)
Private Declare Sub SetAllDigital Lib "k8055d.dll" ()
Private Declare Function ReadDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer) As Boolean
Private Declare Function ReadAllDigital Lib "k8055d.dll" () As Integer
Private Declare Function ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Integer) As Integer
Private Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Integer)
Private Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Integer, ByVal DebounceTime As Integer)
Dim conn As New MySqlConnection
Dim myCommand As New MySqlCommand
Dim myReader As MySqlDataReader
Function Lichten()
OpenDevice(0)
Dim conn As New MySql.Data.MySqlClient.MySqlConnection
Dim myConnectionString As String
myConnectionString = "server=localhost;" _
& "uid=root;" _
& "pwd=salaat;" _
& "database=eindwerk;"
Try
conn.ConnectionString = myConnectionString
conn.Open()
Catch ex As MySql.Data.MySqlClient.MySqlException
MessageBox.Show(ex.Message)
End Try
Dim SQL As String
SQL = "select Licht from Lichten"
myCommand.Connection = conn
myCommand.CommandText = SQL
Dim uitkomst As Integer
Dim i As Integer
Dim status(8) As Boolean
myReader = myCommand.ExecuteReader
While myReader.Read
uitkomst = myReader.GetInt64(myReader.GetOrdinal("Licht"))
' uitkomst = myReader.GetBoolean(myReader.GetOrdinal("Licht"))
If uitkomst = 1 Then
status(i) = False
End If
If uitkomst = 2 Then
status(i) = True
End If
i = i + 1
End While
If status(0) = True Then
SetDigitalChannel(8)
End If
If status(1) = True Then
SetDigitalChannel(1)
End If
If status(2) = True Then
SetDigitalChannel(2)
End If
If status(3) = True Then
SetDigitalChannel(3)
End If
If status(4) = True Then
SetDigitalChannel(4)
End If
If status(5) = True Then
SetDigitalChannel(5)
End If
If status(6) = True Then
SetDigitalChannel(6)
End If
If status(7) = True Then
SetDigitalChannel(7)
End If
myReader.Close()
End Function
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Name = "Form1"
Me.Text = "Form1"
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim altijd As Integer
While (altijd < 1)
Lichten()
End While
'SetAllDigital()
CloseDevice()
End Sub
End Class
My vb.net program must run always, with that reason i make ‘a non stop while’
But after some time if got a popup error =>
Error connecting: timeout expired. the timeout period alapsed prior to obtaining a connection from the pool. This may have oocurred because all pooled connections were in use and max pool size was reached.
My server is XAMPP (apache).
What can i do?