Jump to content

SQLite: unable to insert value


Recommended Posts

#include <SQLite.au3>
#include <SQLite.dll.au3>
$name = "Hacker"
$con = "xxxxxxxxx"
$mob = "HTC One X"
$fult = "Software"
$est = "400"
$time = "192812"
$date = "900902"
Local $hQuery, $aRow, $sMsg
_SQLite_Startup()
_SQLite_Open('customer_database.db')
_SQLite_Exec(-1, "CREATE TABLE Customer (Name,Contact,Mobile,Fult,Estimate,Time,Date);") 
_SQLite_Exec(-1, "INSERT INTO Customer(Name,Contact,Mobile,Fult,Estimate,Time,Date) VALUES" & ($name,$con,$mob,$fult,$est,$time,$date )
_SQLite_Query(-1, "SELECT c FROM aTest ORDER BY a;", $hQuery)
_SQLite_Close()
_SQLite_Shutdown()

Where i am wrong ? >_<

Edited by verma123
Link to comment
Share on other sites

Probably where the error pops up.

#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <Array.au3>

Local $name = "Hacker"
Local $con = "xxxxxxxxx"
Local $mob = "HTC One X"
Local $fult = "Software"
Local $est = "400"
Local $time = "192812"
Local $date = "900902"
Local $aRows, $iRows, $iCols

_SQLite_Startup()
_SQLite_Open('customer_database.db')

_SQLite_Exec(-1, "CREATE TABLE if not exists Customer (Name TEXT, Contact TEXT, Mobile TEXT, Fult TEXT, Estimate TEXT, Time TEXT, Date TEXT);")
_SQLite_Exec(-1, "INSERT INTO Customer(Name, Contact, Mobile, Fult, Estimate, Time, Date) " & _
                    "VALUES ("& _SQLite_FastEscape($name) & "," & _
                                _SQLite_FastEscape($con) & "," & _
                                _SQLite_FastEscape($mob) & "," & _
                                _SQLite_FastEscape($fult) & "," & _
                                $est & "," & _
                                $time & "," & _
                                $date & ");")
_SQLite_GetTable2d(-1, "SELECT Contact FROM customer;", $aRows, $iRows, $iCols)
_ArrayDisplay($aRows)

_SQLite_Close()
_SQLite_Shutdown()

Keep away from _SQLite_Query. Prefer *_GetTable[2d] or *_QuerySingleRow.

Declare SQLite types. Escape literal strings.

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 here
RegExp tutorial: enough to get started
PCRE 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

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
 Share

×
×
  • Create New...