我正在尝试GNOME JavsScript 教程,这似乎不适用于其原始版本。
var gdaStrConn = Gda.Connection.open_from_string("SQLite", "DB_DIR=" + GLib.get_home_dir () + ";DB_NAME=gnome_demo", null, 0);
print('Connected');
gdaStrConn.execute_non_select_command (this.connection, 'create table demo (id integer, name varchar(100))');
该函数的文档execute_non_select_command
说:
gint gda_connection_execute_non_select_command
(GdaConnection *cnc,
const gchar *sql,
GError **error);
This is a convenience function to execute a SQL command over the opened connection. For the returned value, see gda_connection_statement_execute_non_select()'s documentation.
cnc : an opened connection
sql : a query statement that must not begin with "SELECT"
error : a place to store errors, or NULL
Returns : the number of rows affected or -1, or -2
现在我收到以下错误:
(gjs:25295): Gjs-WARNING **: JS ERROR: Error: Expected type utf8 for Argument 'sql' but got type 'object'
为什么我得到那个错误,因为sql
参数是一个字符串:'create table demo (id integer, name varchar(100))'
?
那个电话有什么问题?