问题
My problem is I am unable to insert values into sqlite3 using autohot key.
My code is:
MyName := name
myTel := telphonenumber
$sSQL := "insert into myTable Values ('" %MyName% "', " %myTel% ");"
and I also tried with ,
$sSQL := "insert into myTable Values ( ' " . MyName . " ', " . myTel . ");"
But neither of these works.
Any suggestion is appreciated..
回答1:
I've not used AHK with SQLite before, but is it just the query you're having issues with? Try this (note the lack of the colon before the equals sign):
$sSQL = "insert into myTable Values ('%MyName%', '%myTel%');"
Your second attempt produces a query that is technically valid, but it would put a space either side of the name in the database ('John' would be ' John '). Also I'm guessing you don't really want to be using a numeric field in your database for a telephone number? If a number begins with 0 or is to large you could have issues. The version above will insert it as a string.
回答2:
MyName := name
myTel := telphonenumber
$sSQL := "insert into myTable Values ('" MyName "', '" myTel "');"
I prefer to put the phone number also into apostrophe. if you do not have a phone number then there is no error:
insert into myTable Values ('John', '' );
and as Gary said right: "If a number begins with 0 or ... issues."
the select of the telephone number
0177... will give you later 177...
better you also use a string for the phone number and not an number format.
create table myTable
(
name TEXT
phone TEXT
) ;
来源:https://stackoverflow.com/questions/6294494/how-to-insert-values-into-sqlite3-using-autohotkey