alias dbWrite {
; Alter this SQL statement to use the correct TableName and FieldNames, and of course
; the values you wish to add to the database. This could be made much more dynamic,
; but for the purpose of showing how to get it working, a simpler version suffices.
;
var %SQL = $&[color:#00007F]
INSERT INTO MyTable (Nick, Channel, CurrentUsers, CTime) $&
VALUES (' $+ $nick $+ ', ' $+ $chan $+ ', $nick($chan,0) $+ , $ctime $+ );
[/color]
; Put the exact path (D:\path\to\filename.mdb) to your Access database here.
;
var %DBPath = [color:#840017]$mircdir $+ MyDB.mdb[/color]
; This statement is complete, do not touch.
;
var %ConnectionString = Provider=Microsoft.JET.OLEDB.4.0;Data Source= $+ %DBPath
; Instantiate a Connection object.
;
.comopen cnMyDB ADODB.Connection
; Attempt to connect the Connection object to your database.
;
if ($com(cnMyDB, Open, 5, bstr, %ConnectionString) == 0) {
; If we're in here, we didn't connect to the database; issue an error message.
;
echo $color(ctcp) -ati * COM could not open the database.
; Close the COM connection
;
.comclose cnMyDB
; Halt the script on an error condition.
;
halt
}
; If we're here, the database is open, ready to write to.
;
!.echo -q $com(cnMyDB, Execute, 5, bstr, %SQL)
; Close down the Connection object (destroy it).
;
.comclose cnMyDB
}