Jump to content

[Solved] Strange problem with SQLite and AutoIt


gimx
 Share

Recommended Posts

Hello,

I must insert datas in SQLite DB with this code but it don't work.

_SQLite_Exec(-1, 'Insert into partant(crse, numero, cheval, deferre, distance, chevalmus, idfc, driver, drivermus, trainer, trainermus) values("' & $crse & '","' & $numero & '","' & $cheval & '","' & $deferre & '","' & $distance & '","' & $chevalmus & '","' & $idfc & '","' & $driver & '","' & $drivermus & '","' & $trainer & '","' & $trainermus & '");')

; MsgBox(0, "", $crse & "-" & $numero & "-" & $cheval & "-" & $deferre & "-" & $distance & "-" & $chevalmus & "-" & $idfc & "-" & $driver & "-" & $drivermus & "-" & $trainer & "-" & $trainermus)

I try to "uncomment" (sorry for my english) the msgbox line and all values are in the box.

When i try to insert values with _SQLite_Exec, the db line is empty.

So i try to insert value by value and i identify the wrong value, it's $idfc.

If i insert values in BD without $idfc, it work. If i try to insert $idfc with other values, the row in db is empty.

$idfc is a numeric value (positive or negative).

In db, the column idfc is set to real (i've tried with text, float, numeric, it's the same problem).

I don't understand why the value is displayed properly with the MsgBox and when i try to insert this value with others it don't work.

I hope i'm clear in my explanation...

Thx for help :)

Edited by gimx
Link to comment
Share on other sites

Hello,

I must insert datas in SQLite DB with this code but it don't work.

_SQLite_Exec(-1, 'Insert into partant(crse, numero, cheval, deferre, distance, chevalmus, idfc, driver, drivermus, trainer, trainermus) values("' & $crse & '","' & $numero & '","' & $cheval & '","' & $deferre & '","' & $distance & '","' & $chevalmus & '","' & $idfc & '","' & $driver & '","' & $drivermus & '","' & $trainer & '","' & $trainermus & '");')

; MsgBox(0, "", $crse & "-" & $numero & "-" & $cheval & "-" & $deferre & "-" & $distance & "-" & $chevalmus & "-" & $idfc & "-" & $driver & "-" & $drivermus & "-" & $trainer & "-" & $trainermus)

I try to "uncomment" (sorry for my english) the msgbox line and all values are in the box.

When i try to insert values with _SQLite_Exec, the db line is empty.

So i try to insert value by value and i identify the wrong value, it's $idfc.

If i insert values in BD without $idfc, it work. If i try to insert $idfc with other values, the row in db is empty.

$idfc is a numeric value (positive or negative).

In db, the column idfc is set to real (i've tried with text, float, numeric, it's the same problem).

I don't understand why the value is displayed properly with the MsgBox and when i try to insert this value with others it don't work.

I hope i'm clear in my explanation...

Thx for help ;)

Show the line of code where you created the table and assigned the column types. It works fine with default types and numeric values:
#include <sqlite.au3>
#include <sqlite.dll.au3>

Global $hQuery, $aRow
Global $crse = 1, $numero = 2, $cheval = 3, $deferre = 4, $distance = 5, $chevalmus = 6
Global $idfc = 7, $driver = 8, $drivermus = 9, $trainer = 10, $trainermus = 11

_SQLite_Startup()
_SQLite_Open()

; Create table
_SQLite_Exec(-1,'Create table partant (crse, numero, cheval, deferre, distance, ' & _
    'chevalmus, idfc, driver, drivermus, trainer, trainermus);')
    
; Add a row of data
_SQLite_Exec(-1, 'Insert into partant(crse, numero, cheval, deferre, distance, ' & _
    'chevalmus, idfc, driver, drivermus, trainer, trainermus) values("' & $crse & '","' & _
    $numero & '","' & $cheval & '","' & $deferre & '","' & $distance & '","' & $chevalmus & _
    '","' & $idfc & '","' & $driver & '","' & $drivermus & '","' & $trainer & '","' & $trainermus & '");')

; Query the data
_SQLite_Query(-1, "Select * From partant", $hQuery)
_SQLite_FetchData($hQuery, $aRow)
_SQLite_QueryFinalize($hQuery)

For $n = 0 To UBound($aRow) - 1
    ConsoleWrite("Data " & $n & ": " & $aRow[$n] & @LF)
Next

_SQLite_Close()
_SQLite_Shutdown()

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thx for your reply.

Today, i boot my computer and run the script.

And it works... :)

Really i don't know why it doesn't work yesterday.

Stupid PC (or stupid me maybe :D ).

Thx ;)

Edited by gimx
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...