Ace08 Posted July 6, 2011 Share Posted July 6, 2011 Hi there i have here a script that connects to a certain database and returns names and addresses based on the ID, its working if the value queried exists however if not i'am getting an error "Either BOF or EOF is True, or the correct record has been deleted.requested operation requires a current record.". ; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $conn = ObjCreate( "ADODB.Connection" ) $DSN = "DRIVER={SQL Server};SERVER=ServerName;DATABASE=Database;UID=UserID;PWD=Password;" $conn.Open($DSN) $rs = ObjCreate( "ADODB.RecordSet" ) $rs.Open( "select LastName,FirstName,MiddleInitial,Address1,Address2,City from Table where ID = '015000040277'",$conn ) MsgBox(0,"",$rs.Fields(0).value) Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Exit Endfunc Does anyone know how to deal with the error i've tried to do something like If Not $rs.Fields(0).value = "" Then MsgBox(0,"",$rs.Fields(0).value) EndIf but it seems like when i try to extract a non existing value from $rs.Fields(0).value triggers this error. would appreciate your help. Work smarter not harder.My First Posted Script: DataBase Link to comment Share on other sites More sharing options...
jchd Posted July 6, 2011 Share Posted July 6, 2011 An empty set is _not_ an error. If Not $rs.EOF Then MsgBox(0,"",$rs.Fields(0).value) Else MsgBox(0, "", "No record found") Endif This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Ace08 Posted July 6, 2011 Author Share Posted July 6, 2011 Thanks jchd i know its not an error, but an empty set should return an empty string thats what i think. Thanks a lot its now working Work smarter not harder.My First Posted Script: DataBase Link to comment Share on other sites More sharing options...
jchd Posted July 6, 2011 Share Posted July 6, 2011 I hope not! An empty string means arecord _has_ been found and the field holds an empty string. Quite a difference This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now