Sign in to follow this  
Followers 0
tamnguyen

INSERT VALUES INTO DATABASE

2 posts in this topic

Hi all!

I create a GUI have  2 inputs, and a button "OK" and i create a database, and create a table that is named "MY_DATABASE".

Now, i want to type value into input and then i click OK, i will have data in MY_DATABASE. This is my code!

$data_ID = GUICtrlRead($input_ID)

$data_Name = GUICtrlRead($input_name)

_SQLite_Startup()
_SQLite_Open($Name_Database)

_SQLite_Exec(-1, "INSERT INTO MY_DATABASE ("& $data_ID &","& $data_Name &");")

;--------------

I type into input_ID: 9000

I type into input_Name: nguyenchitam

when i click OK it have a error

!   SQLite.au3 Error
--> Function: _SQLite_Exec
--> Query:    INSERT INTO MY_DATABASE VALUES (9000,nguyenchitam);
--> Error:    no such column: nguyenchitam
 
But when i type
:I type into input_ID: 9000

I type into input_Name: 123

---> IT's good and i have a data in MY_DATABASE

Can anyone help me? I want to have a data with typedata is text

Share this post


Link to post
Share on other sites



You should wrap the variable data in single quotes, ie:

_SQLite_Exec(-1, "INSERT INTO MY_DATABASE ('"& $data_ID &"','"& $data_Name &"');")

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