ADODB-Zugriffsmethoden. Mehr ...
Öffentliche Methoden | |
Event | ErrorMissingCurrentConnection (ByVal Msg As String, ByRef NewCurrentConnection As ADODB.Connection) |
Ereignis für fehlende ADODB-Connection-Referenz. | |
Event | ErrorEmptyConnectionString (ByVal Msg As String, ByRef NewConnectionString As String) |
Ereignis für fehlenden OLEDB-Connectionstring. | |
Property Get | CurrentConnection () As ADODB.Connection |
Aktuell eingestellte ADODB-Connction. | |
Property Set | CurrentConnection (ByRef NewConnection As ADODB.Connection) |
Übergabe einer ADODB-Connection. | |
Property Get | ConnectionString () As String |
OLEDB-Connectionstring. | |
Property Let | ConnectionString (ByVal sConnectionString As String) |
OLEDB-Connectionstring. | |
Function | Execute (ByVal CommandText As String, Optional ByRef RecordsAffected As Long, Optional ByVal Options As ADODB.ExecuteOptionEnum=-1) As ADODB.Recordset |
Execute. | |
Function | OpenRecordset (ByVal Source As String, Optional ByVal CursorType As ADODB.CursorTypeEnum=ADODB.CursorTypeEnum.adOpenForwardOnly, Optional ByVal LockType As ADODB.LockTypeEnum=ADODB.LockTypeEnum.adLockReadOnly, Optional ByVal CursorLocation As ADODB.CursorLocationEnum=ADODB.CursorLocationEnum.adUseServer, Optional ByVal DisconnectedRecordset As Boolean=False) As ADODB.Recordset |
OpenRecordset. | |
Function | OpenRecordsetCommandParam (ByVal CmdText As String, ByVal CmdType As ADODB.CommandTypeEnum, Optional ByVal commandParamDefs As Variant) As ADODB.Recordset |
Recocordset mittels ADODB.Command öffnen. | |
Function | DLookupSQL (ByVal sSQL As String, Optional ByVal index As Variant=0 &) As Variant |
DLookup-Recordset-Ersatzfunktion für Übergabe einer vollständigen SQL-Anweisung. | |
Function | DLookup (ByVal Expr As String, ByVal Domain As String, Optional ByVal Criteria As Variant) As Variant |
DLookup-Recordset-Ersatzfunktion. | |
Function | DCount (ByVal Expr As String, ByVal Domain As String, Optional ByVal Criteria As Variant) As Long |
DCount-Recordset-Ersatzfunktion. | |
Function | DMax (ByVal Expr As String, ByVal Domain As String, Optional ByVal Criteria As Variant) As Variant |
DMax-Recordset-Ersatzfunktion. | |
Function | DMin (ByVal Expr As String, ByVal Domain As String, Optional ByVal Criteria As Variant) As Variant |
DMin-Recordset-Ersatzfunktion. | |
Function | DSum (ByVal Expr As String, ByVal Domain As String, Optional ByVal Criteria As Variant) As Variant |
DSum-Recordset-Ersatzfunktion. | |
Function | InsertIdentityReturn (ByVal InsertSQL As String, Optional ByVal IdentityTable As String=vbNullString) As Variant |
Insert-SQL-Anweisung ausführen und letzten Identity-Wert (Autowert) zurückgeben. |
ADODB-Zugriffsmethoden.
Property Let ConnectionString | ( | ByVal sConnectionString As | String | ) |
OLEDB-Connectionstring.
sConnectionString | OLEDB-Connectionstring für den Verbindungaufbau |
Property Get ConnectionString | ( | ) |
OLEDB-Connectionstring.
Property Set CurrentConnection | ( | ByRef NewConnection As ADODB. | Connection | ) |
Übergabe einer ADODB-Connection.
NewConnection | Neue ADODB-Connection |
Property Get CurrentConnection | ( | ) |
Aktuell eingestellte ADODB-Connction.
Falls noch keine ADODB-Connection vorhanden ist, wird eine neue ADODB-Verbindung erstellt. Ablauf der Instanzieren: 1. RaiseEvent ErrorMissingCurrentConnection ... falls keine Connection übergeben wurde: 2. Neue ADODB-Connection auf Basis des OLEDB-Connectionstring erzeugen (Einsatz der Eigenschaft ConnectionString)
Falls bereits eine Referenz zu einer ADODB-Connection vorhanden ist, wird geprüft, ob diese geschlossen ist und im Bedarfsfall geöffnet.
Function DCount | ( | ByVal Expr As | String, | |
ByVal Domain As | String, | |||
Optional ByVal Criteria As | Variant | |||
) |
DCount-Recordset-Ersatzfunktion.
Expr | Feldname oder berechneter Ausdruck (Select-Teil) | |
Domain | Tabelle, Abfrage oder SQL-Ausdruck für Sub-Abfrage (FROM-Teil) | |
Criteria | Filter (WHERE-Teil) |
Function DLookup | ( | ByVal Expr As | String, | |
ByVal Domain As | String, | |||
Optional ByVal Criteria As | Variant | |||
) |
DLookup-Recordset-Ersatzfunktion.
Expr | Feldname oder berechneter Ausdruck (Select-Teil) | |
Domain | Tabelle, Abfrage oder SQL-Ausdruck für Sub-Abfrage (FROM-Teil) | |
Criteria | Filter (WHERE-Teil) |
Function DLookupSQL | ( | ByVal sSQL As | String, | |
Optional ByVal index As | Variant = 0 & | |||
) |
DLookup-Recordset-Ersatzfunktion für Übergabe einer vollständigen SQL-Anweisung.
sSQL | SQL-Anweisung | |
Index | Feldauswahl, falls nicht das erste Feld des Recordsets zurückgeliefert werden soll. Die Index-Übergabe erfolgt analaog ADODB.Recordset.Fields(index) |
Die SQL-Anweisung ist im SQL-Dialekt des betroffenen DBMS zu schreiben.
Function DMax | ( | ByVal Expr As | String, | |
ByVal Domain As | String, | |||
Optional ByVal Criteria As | Variant | |||
) |
DMax-Recordset-Ersatzfunktion.
Expr | Feldname oder berechneter Ausdruck (Select-Teil) | |
Domain | Tabelle, Abfrage oder SQL-Ausdruck für Sub-Abfrage (FROM-Teil) | |
Criteria | Filter (WHERE-Teil) |
Function DMin | ( | ByVal Expr As | String, | |
ByVal Domain As | String, | |||
Optional ByVal Criteria As | Variant | |||
) |
DMin-Recordset-Ersatzfunktion.
Expr | Feldname oder berechneter Ausdruck (Select-Teil) | |
Domain | Tabelle, Abfrage oder SQL-Ausdruck für Sub-Abfrage (FROM-Teil) | |
Criteria | Filter (WHERE-Teil) |
Function DSum | ( | ByVal Expr As | String, | |
ByVal Domain As | String, | |||
Optional ByVal Criteria As | Variant | |||
) |
DSum-Recordset-Ersatzfunktion.
Expr | Feldname oder berechneter Ausdruck (Select-Teil) | |
Domain | Tabelle, Abfrage oder SQL-Ausdruck für Sub-Abfrage (FROM-Teil) | |
Criteria | Filter (WHERE-Teil) |
Event ErrorEmptyConnectionString | ( | ByVal Msg As | String, | |
ByRef NewConnectionString As | String | |||
) |
Ereignis für fehlenden OLEDB-Connectionstring.
Msg | Meldung über Ursache der Ereignisauslösung. (Wird noch nicht genutzt) | |
NewConnectionString | OLEDB-Connectionstring |
über den ByRef-Parameter NewConnectionString kann der passende OLEDB-Connectionstring weitergegeben werden.
Event ErrorMissingCurrentConnection | ( | ByVal Msg As | String, | |
ByRef NewCurrentConnection As ADODB. | Connection | |||
) |
Ereignis für fehlende ADODB-Connection-Referenz.
Msg | Meldung über Ursache der Ereignisauslösung. (Wird noch nicht genutzt) | |
NewCurrentConnection | ADODB.Connection-Referenz, die für CurrentConnection verwendet werden soll |
Über den ByRef-Parameter NewCurrentConnection kann die passende ADODB.Database-Referenz weitergegeben werden. Eine Referenz-Weitergabe ist allerdings nicht zwingend erforderlich, da z. B. in der Methode CurrentConnection die Connection dann aus dem ConnectionString erstellt wird.
Function Execute | ( | ByVal CommandText As | String, | |
Optional ByRef RecordsAffected As | Long, | |||
Optional ByVal Options As ADODB. | ExecuteOptionEnum = -1 | |||
) |
Execute.
CommandText | SQL-Anweisung | |
RecordsAffected | ByRef-Parameter zur Rückgabe der Anzahl der von der Execute-Anweisung betroffenen Datensätze | |
Options | zusäztliche Optionen der ADODB.Connection-Execute-Methode |
Kapselung der ADODB.Connection.Execute-Methode (Parameter werden 1:1 weitergereicht)
Function InsertIdentityReturn | ( | ByVal InsertSQL As | String, | |
Optional ByVal IdentityTable As | String = vbNullString | |||
) |
Insert-SQL-Anweisung ausführen und letzten Identity-Wert (Autowert) zurückgeben.
InsertSQL | Insert-SQL-Anweisung (INSERT ...) |
Funktioniert für Jet erst ab Jet 4.0 (Access 2000), IdentityTable ist nur für MSSQL anwendbar, unter MySQL gibt es die Funktion IDENT_CURRENT nicht.
Function OpenRecordset | ( | ByVal Source As | String, | |
Optional ByVal CursorType As ADODB. | CursorTypeEnum = ADODB.CursorTypeEnum.adOpenForwardOnly , |
|||
Optional ByVal LockType As ADODB. | LockTypeEnum = ADODB.LockTypeEnum.adLockReadOnly , |
|||
Optional ByVal CursorLocation As ADODB. | CursorLocationEnum = ADODB.CursorLocationEnum.adUseServer , |
|||
Optional ByVal DisconnectedRecordset As | Boolean = False | |||
) |
OpenRecordset.
Source | Datenquelle (z.B. SQL-Anweisung) | |
CursorType | ADODB.CursorTypeEnum-Wert | |
LockType | ADODB.LockTypeEnum-Wert | |
CursorLocation | ADODB.CursorLocationEnum-Wert | |
DisconnectedRecordset | True: Verbindung nach Öffnen des Recordset kappen ... verbindungsloses Recordset |
Function OpenRecordsetCommandParam | ( | ByVal CmdText As | String, | |
ByVal CmdType As ADODB. | CommandTypeEnum, | |||
Optional ByVal commandParamDefs As | Variant | |||
) |
Recocordset mittels ADODB.Command öffnen.
CmdText | ADODB.CommandText-Wert | |
CmdType | ADODB.CommandType-Wert | |
commandParamDefs | 2-dimensionales Parameter-Array (Array(n,1) ... x(n,0) = Parametername, x(n,0) = Parameterwert) ... abwechselnd Paramtername und Parameterwert einstellen |
Mit dieser Variante kann sehr einfach SQL-Injection vermieden werden, da die Parameter nicht direkt in der SQL-Anweisung eingebaut sind und somit ein Parameterwert (der z. B. von einer Benutzereingabe stammt) keine SQL-Anweisung einschleusen kann.