anandchakru Posted May 3, 2009 Posted May 3, 2009 #include <SQLite.au3> #include <SQLite.dll.au3> Local $hQuery, $aRow, $aNames, $sMsg _SQLite_Startup () _SQLite_Open ("test.db") _SQLite_Exec(-1,"CREATE TABLE IF NOT EXISTS T (varchar2 blob);") $sData = _SQLite_Encode(Binary("Hello")) _SQLite_Exec(-1,"INSERT INTO T VALUES ( " & $sData & " );") _SQLite_Query(-1,"SELECT * FROM T;",$hQuery) _SQlite_Query (-1, "SELECT ROWID,* FROM T;", $hQuery) _SQLite_FetchNames ($hQuery, $aNames) While _SQLite_FetchData ($hQuery, $aRow,1) = $SQLITE_OK ConsoleWrite(($aRow[0])) $sMsg &= Hex($aRow[0]) & @CR WEnd _SQLite_Close () _SQLite_Shutdown () I keep getting this error, wats worng here? can anybody please help 1! SQLite.au3 Error --> Function: _SQLite_Close --> Error: Unable to close due to unfinalised statements [font="Book Antiqua"]Thanks`A[/font]
Zinthose Posted May 4, 2009 Posted May 4, 2009 (edited) The issue is with the first query not being finalized before the second is executed. Since you don't read the data from the first query, you can simply comment it out and the script works.If you want to keep it in there for the sake of knowing how to leave it in there, you use the "_SQLite_QueryFinalize" function. Result:#include <SQLite.au3> #include <SQLite.dll.au3> Local $hQuery, $aRow, $aNames, $sMsg _SQLite_Startup () _SQLite_Open ("test.db") _SQLite_Exec(-1,"CREATE TABLE IF NOT EXISTS T (varchar2 blob);") $sData = _SQLite_Encode(Binary("Hello")) _SQLite_Exec(-1,"INSERT INTO T VALUES ( " & $sData & " );") _SQLite_Query(-1,"SELECT * FROM T;",$hQuery); <-- Issue is here _SQLite_QueryFinalize($hQuery); <-- Fix is finallizing the previous query _SQlite_Query (-1, "SELECT ROWID,* FROM T;", $hQuery) _SQLite_FetchNames ($hQuery, $aNames) While _SQLite_FetchData ($hQuery, $aRow,1) = $SQLITE_OK ConsoleWrite(($aRow[0])) $sMsg &= Hex($aRow[0]) & @CR WEnd _SQLite_Close () _SQLite_Shutdown ()Fixed Sleepy Programmer Error Edited May 4, 2009 by Zinthose --- TTFN
anandchakru Posted May 4, 2009 Author Posted May 4, 2009 The issue is with the first query not being finalized before the second is executed. Since you don't read the data from the first query, you can simply comment it out and the script works. If you want to keep it in there for the sake of knowing how to leave it in there, you use the "_SQLite_FetchNames" function. Result: #include <SQLite.au3> #include <SQLite.dll.au3> Local $hQuery, $aRow, $aNames, $sMsg _SQLite_Startup () _SQLite_Open ("test.db") _SQLite_Exec(-1,"CREATE TABLE IF NOT EXISTS T (varchar2 blob);") $sData = _SQLite_Encode(Binary("Hello")) _SQLite_Exec(-1,"INSERT INTO T VALUES ( " & $sData & " );") _SQLite_Query(-1,"SELECT * FROM T;",$hQuery); <-- Issue is here _SQLite_QueryFinalize($hQuery); <-- Fix is finallizing the previous query _SQlite_Query (-1, "SELECT ROWID,* FROM T;", $hQuery) _SQLite_FetchNames ($hQuery, $aNames) While _SQLite_FetchData ($hQuery, $aRow,1) = $SQLITE_OK ConsoleWrite(($aRow[0])) $sMsg &= Hex($aRow[0]) & @CR WEnd _SQLite_Close () _SQLite_Shutdown () Thank you verymuch, Zinthose [font="Book Antiqua"]Thanks`A[/font]
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