Chaguito
Getting the hang of it
Registered: 2002-05-17
Posts: 53
|
Quote:
I'm attempting to update an access database with the below script. It doesn't work. I've been working on this thing all day! Can someone help? Below is the code.
I can insert the first record just fine, but my code for the update never gets touched.
On my Access database, the field MAC is a primary key.
Code:
$objConn = DBConnOpen('DRIVER={Microsoft Access Driver (*.mdb)}; UID=; PWD=; DBQ=\\ngne-j6-05\test\erictest.mdb') $recordset = DBGetRecordset($objConn,"SELECT MAC FROM Table1 WHERE MAC='$MACADDR'") If $recordset.recordcount <> 1 for each $record in $recordset $=Messagebox("Getting Here!","return code") $recordsetfields=split($record,chr(10)) for each $field in $recordsetfields $retcode = DBExecuteSQL($objConn,"UPDATE Table1(DateWritten,TimeWritten,Workstation,IP,Cpu,RAM,OS,ServicePack,IEVER,MSOfficeVer,UserID,FullName) VALUES('$DATEWRITTEN','$TIMEWRITTEN','$WKSTA','$IPADDRESS','$CPUMHZ','$RAM','$VerboseOs','$OSCSDVersion','$IeCurVer','$OfficeCurVer','$UserID','($FullName)')") next next Else ; This means that there is no record in the table that contains this MAC. Insert record now.... $=Messagebox("You are here!!!!","return code") $retcode = DBExecuteSQL($objConn,"INSERT INTO Table1(DateWritten,TimeWritten,Workstation,IP,MAC,Cpu,RAM,OS,ServicePack,IEVER,MSOfficeVer,UserID,FullName) VALUES('$DATEWRITTEN','$TIMEWRITTEN','$WKSTA','$IPADDRESS','$MACADDR','$CPUMHZ','$RAM','$VerboseOs','$OSCSDVersion','$IeCurVer','$OfficeCurVer','$UserID','($FullName)')") EndIf
Instead of using
If $recordset=''
use
IF UBOUND($recordset)=-1
This means that if recordset is empty. I tried it the same way you did and most of the times gave me errors.
_________________________
Chaguito, MCP
|