Hallo,
Problem: Bei der Verbindung mit der Mysql Datenbank tritt immerwieder das "to many Connections" Problem auf.
Versuch der Lösung durch eine eigene Klasse:
Problem dieses Lösungsversuches: Aufruf rec("Name").Value ist nicht möglich. Dh. so ist es nicht möglich die Werte einer Spalte aufzurufen.
Gruß
Foogo
Problem: Bei der Verbindung mit der Mysql Datenbank tritt immerwieder das "to many Connections" Problem auf.
Versuch der Lösung durch eine eigene Klasse:
VB.NET-Quellcode
- Public Class dbRecordset
- Public Sub New(sSQL As String)
- _sSQL = sSQL
- Loadparameter()
- End Sub
- Private _rec As ADODB.Recordset
- Private _dbRecordset As ADODB.Recordset
- Private _cursorType As ADODB.CursorTypeEnum = adOpenDynamic
- Private _lockType As ADODB.LockTypeEnum = adLockOptimistic
- Private _cursorLocation As ADODB.CursorLocationEnum = adUseClient
- Private _sSQL As String
- Private _oConn1 As ADODB.Connection
- Public Property rec As ADODB.Recordset
- Get
- Return _rec
- End Get
- Set(value As ADODB.Recordset)
- _rec = value
- End Set
- End Property
- Public Property CursorType As ADODB.CursorTypeEnum
- Get
- Return _cursorType
- End Get
- Set(value As ADODB.CursorTypeEnum)
- _cursorType = value
- End Set
- End Property
- Public Property LockType As ADODB.LockTypeEnum
- Get
- Return _lockType
- End Get
- Set(value As ADODB.LockTypeEnum)
- _lockType = value
- End Set
- End Property
- Public Property CursorLocation As ADODB.CursorLocationEnum
- Get
- Return _cursorLocation
- End Get
- Set(value As ADODB.CursorLocationEnum)
- _cursorLocation = value
- End Set
- End Property
- Public Property sSQL As String
- Get
- Return _sSQL
- End Get
- Set(value As String)
- _sSQL = value
- End Set
- End Property
- Public Property oConn1 As ADODB.Connection
- Get
- Return _oConn1
- End Get
- Set(value1 As ADODB.Connection)
- _oConn1 = value1
- End Set
- End Property
- Public Sub Loadparameter()
- Dim _oConn1 As New ADODB.Connection
- _oConn1.Open(FConnStrg.ConnectionStrg)
- Try
- _rec = New ADODB.Recordset
- With _rec
- .CursorLocation = CursorLocation
- 'MsgBox(sSQL)
- .Open(sSQL, _oConn1, CursorType, LockType)
- End With
- Catch ex As Exception
- MsgBox(ex.ToString)
- End Try
- End Sub
- Public Sub Close()
- rec.Close()
- oConn1.Close()
- End Sub
- End Class
- '-----------------------AUFRUF
- Dim recordset As New dbRecordset("SELECT * FROM daten")
- Do Until recordset.rec.EOF = True
- With recordset
- .rec("Name").Value
- .rec.MoveNext()
- End With
- Loop
- .rec.close()
Problem dieses Lösungsversuches: Aufruf rec("Name").Value ist nicht möglich. Dh. so ist es nicht möglich die Werte einer Spalte aufzurufen.
Gruß
Foogo