|
|
|
| 13 May 2002 | DBExecuteSQL() |
| Author | Jens Meyer (sealeopard@usa.net) |
| Action | Executes a SQL command on a database. |
| Syntax | DBExecuteSQL (connection, SQL [,cmdType]) |
| Parameters | |
| Remarks | This routine does not return a recordset as the result of the SQL statement. Therefore, it should only be used with SQL commands like INSERT INTO, UPDATE. For SELECT statements one should rather use DBGetRecordset(). KIXTART BBS http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000196 |
| Returns | 0 if successful, otherwise error code |
| Dependencies | KiXtart 4.02 (there have been reports of this function not working under KiXtart 4.10) |
| Examples |
$objConn = DBConnOpen('DRIVER={Microsoft Access Driver (*.mdb)}; UID=; PWD=; DBQ=database.mdb')
$retcode = DBExecuteSQL($objConn,"INSERT INTO Demo(Field1,Field2) VALUES('Value1','Value2'")
$retcode = DBConnClose($objConn)
|
| Source |
FUNCTION DBExecuteSQL ($objconn, $sql, OPTIONAL $cmdtype)
DIM $cmdcommand, $rsrecordset
DIM $adcmdunspecified, $adcmdtext, $adcmdtable, $adcmdstoredproc, $adcmdunknown, $adcmdfile, $adcmdtabledirect
$adcmdunspecified = -1
$adcmdtext = 1
$adcmdtable = 2
$adcmdstoredproc = 4
$adcmdunknown = 8
$adcmdfile = 256
$adcmdtabledirect = 512
IF VarType($cmdtype)
$cmdtype=Val($cmdtype)
ELSE
$cmdtype=$adcmdtext
ENDIF
IF VarType($objconn) <> 9 OR $sql = ''
EXIT 87
ENDIF
$cmdcommand = CreateObject('ADODB.Command')
IF @error
EXIT @error
ENDIF
$cmdcommand.activeconnection = $objconn
IF @error
EXIT @error
ENDIF
$cmdcommand.commandtype = $cmdtype
IF @error
EXIT @error
ENDIF
$cmdcommand.commandtext = $sql
IF @error
EXIT @error
ENDIF
$rsrecordset=$cmdcommand.execute()
$cmdcommand=''
$rsrecordset=''
IF @error
EXIT @error
ENDIF
$dbexecutesql=@error
ENDFUNCTION ; - DBExecuteSQL -
|
|
|
|