[英]Lua insert statement
我的插入语句有问题:
Create = function (LN,FN,Add,Tel,Cell)
LastName = tostring(LN);
FirstName = tostring(FN);
Address = tostring(Add);
Telephone =tostring(Tel);
Cellphone = tostring(Cell);
-问题的根源
conn:execute([[INSERT INTO book(LastName, FirstName, Address, Telephone, Cellphone) VALUES ("]]"'"LastName"','"FirstName"','" Address"','" Telephone"','" Cellphone")]]'")
print ("\n Creating an account Successful")
end
我建议您使用string.format
放置数据:
Create = function (LN,FN,Add,Tel,Cell)
local LastName, FirstName, Address, Telephone, Cellphone = tostring(LN), tostring(FN), tostring(Add), =tostring(Tel), tostring(Cell)
local sQuery = [[INSERT INTO book(LastName, FirstName, Address, Telephone, Cellphone) VALUES ('%s', '%s', '%s', '%s', '%s')]]
conn:execute( sQuery:format(LastName, FirstName, Address, Telephone, Cellphone) )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.