0

元のバージョンでは動作しないように思われる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))'ですか?

その呼び出しの何が問題になっていますか?

4

1 に答える 1

1

3 行目で、関数の最初の引数を省略します。したがって、行は次のようになります。

gdaStrConn.execute_non_select_command ('create table demo (id integer, name varchar(100))');

なぜこれが機能するのかわかりません.gjsを自分で学習しているだけです。

于 2015-08-02T06:40:45.270 に答える