Recordset-Klasse

  • VB.NET

Es gibt 5 Antworten in diesem Thema. Der letzte Beitrag () ist von ErfinderDesRades.

    Recordset-Klasse

    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:

    VB.NET-Quellcode

    1. Public Class dbRecordset
    2. Public Sub New(sSQL As String)
    3. _sSQL = sSQL
    4. Loadparameter()
    5. End Sub
    6. Private _rec As ADODB.Recordset
    7. Private _dbRecordset As ADODB.Recordset
    8. Private _cursorType As ADODB.CursorTypeEnum = adOpenDynamic
    9. Private _lockType As ADODB.LockTypeEnum = adLockOptimistic
    10. Private _cursorLocation As ADODB.CursorLocationEnum = adUseClient
    11. Private _sSQL As String
    12. Private _oConn1 As ADODB.Connection
    13. Public Property rec As ADODB.Recordset
    14. Get
    15. Return _rec
    16. End Get
    17. Set(value As ADODB.Recordset)
    18. _rec = value
    19. End Set
    20. End Property
    21. Public Property CursorType As ADODB.CursorTypeEnum
    22. Get
    23. Return _cursorType
    24. End Get
    25. Set(value As ADODB.CursorTypeEnum)
    26. _cursorType = value
    27. End Set
    28. End Property
    29. Public Property LockType As ADODB.LockTypeEnum
    30. Get
    31. Return _lockType
    32. End Get
    33. Set(value As ADODB.LockTypeEnum)
    34. _lockType = value
    35. End Set
    36. End Property
    37. Public Property CursorLocation As ADODB.CursorLocationEnum
    38. Get
    39. Return _cursorLocation
    40. End Get
    41. Set(value As ADODB.CursorLocationEnum)
    42. _cursorLocation = value
    43. End Set
    44. End Property
    45. Public Property sSQL As String
    46. Get
    47. Return _sSQL
    48. End Get
    49. Set(value As String)
    50. _sSQL = value
    51. End Set
    52. End Property
    53. Public Property oConn1 As ADODB.Connection
    54. Get
    55. Return _oConn1
    56. End Get
    57. Set(value1 As ADODB.Connection)
    58. _oConn1 = value1
    59. End Set
    60. End Property
    61. Public Sub Loadparameter()
    62. Dim _oConn1 As New ADODB.Connection
    63. _oConn1.Open(FConnStrg.ConnectionStrg)
    64. Try
    65. _rec = New ADODB.Recordset
    66. With _rec
    67. .CursorLocation = CursorLocation
    68. 'MsgBox(sSQL)
    69. .Open(sSQL, _oConn1, CursorType, LockType)
    70. End With
    71. Catch ex As Exception
    72. MsgBox(ex.ToString)
    73. End Try
    74. End Sub
    75. Public Sub Close()
    76. rec.Close()
    77. oConn1.Close()
    78. End Sub
    79. End Class
    80. '-----------------------AUFRUF
    81. Dim recordset As New dbRecordset("SELECT * FROM daten")
    82. Do Until recordset.rec.EOF = True
    83. With recordset
    84. .rec("Name").Value
    85. .rec.MoveNext()
    86. End With
    87. Loop
    88. .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

    Foogo schrieb:

    Problem: Bei der Verbindung mit der Mysql Datenbank tritt immerwieder das "to many Connections" Problem auf.
    Bei mir nicht.
    Guggemol allgemeine Zugriffs-Lösung für: MySql, Access, SqlCe, SqlServer, DatasetOnly, das PersonBeruf-Sample im Download2010 - das ist eine lauffähige Anwendung, die auf einer MySql im Internet rumorgelt.

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „ErfinderDesRades“ ()

    Danke, aber das erscheint mir etwas komplex für mein Wissensstand. Wenn ich das richtig gesehen habe gehst du über ein Dataset. Und ich will ja nur ein Recordset implementieren. Und auch verstehen warum meine Lösung so nicht klappt.