Sign in to follow this  
Followers 0
diikee

<SOLVED> SQLite query

5 posts in this topic

#1 ·  Posted (edited)

_SQLite_Exec(-1,"Create table Testlog (Date,Test,Status);")
          

If Not _SQLite_Exec (-1, "INSERT INTO Testlog VALUES ("& @MDAY &"/" & @MON &"/" & @YEAR &"," & $ip &"," & "Pass" &");") = $SQLITE_OK Then _
        MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())

; Query
$iRval = _SQLite_GetTable2d (-1, "SELECT * FROM Testlog;", $aResult, $iRows, $iColumns)

If $iRval = $SQLITE_OK Then
    _SQLite_Display2DResult($aResult)
Else
    MsgBox(16, "SQLite Error: " & $iRval, _SQLite_ErrMsg ())
EndIf

! SQLite.au3 Error

--> Function: _SQLite_Exec

--> Query: INSERT INTO Testlog VALUES (15/07/2008,10.100.47.21,Pass);

--> Error: near ".47": syntax error

I want to insert date on the first colum, ip address on the second colum, test results on the third column

what am I missing???

Edited by diikee

Share this post


Link to post
Share on other sites



@diikee..You are missing single quotes in your insert statement...

Do it like this..

"INSERT INTO Testlog VALUES ('"& @MDAY &"/" & @MON &"/" & @YEAR &"','" & $ip &"','" & "Pass" &"');"

Share this post


Link to post
Share on other sites

C:\autoit\vmc.au3 (79) : ==> Unable to parse line.:

"INSERT INTO Testlog VALUES ('"& @MDAY &"/" & @MON &"/" & @YEAR &"','" & $ip &"','" & "Pass" &"');"

^ ERROR

tried your suggestion and got the above error

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Store the SQL statement in a variable first to ensure you have all values:

$SQL = "INSERT INTO Testlog VALUES ('"& @MDAY &"/" & @MON &"/" & @YEAR &"','" & $ip &"','Pass');"
If that works, then:

If Not _SQLite_Exec (-1, $SQL) = $SQLITE_OK Then MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
Edited by DaRam

Share this post


Link to post
Share on other sites

Thanks DaRam

Saving the query to a script was a savior...

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0