windows phone sqlite unrecognized token Exception

Jul 26, 2012 at 6:26 AM
Edited Jul 26, 2012 at 6:27 AM

when i use ExecuteNonQuery method will have this Exception,i batch insert  chinese word ,i insert first record is ok  and than i insert second record is not ok,but if second record is english word will be ok .as follows:

Step1:create batch insert method

public void executeBatch(String[] updateSQLs)
        {
            try
            {
                Open();
                db.BeginTransaction();
                SQLiteCommand cmd = db.CreateCommand("");

                for (int i = 0; i < updateSQLs.Length; i++)
                {
                    cmd.CommandText = updateSQLs[i];
                    cmd.ExecuteNonQuery();
                }
                db.CommitTransaction();
            }
            catch (SQLiteException ex)
            {
                db.RollbackTransaction();
                System.Diagnostics.Debug.WriteLine("executeBatch failed: " + ex.Message);
                throw ex;
            }
        }

Step2:create sql and execute sql(green sql is ok,red sql will have a Exception)

string[] sql = new string[2];
            sql[0] = "Insert into Client_POPDB_property_value (Client_ID, POPDB_ID, Property_ID, Property_value) values (93 ,93 ,348 ,'当代广场旁边')";
            sql[1] = "Insert into Client_POPDB_property_value (Client_ID, POPDB_ID, Property_ID, Property_value) values (93 ,93 ,348 ,'xxx')";
            (Application.Current as App).db.executeBatch(sql);

 

string[] sql = new string[2];
            sql[0] = "Insert into Client_POPDB_property_value (Client_ID, POPDB_ID, Property_ID, Property_value) values (93 ,93 ,348 ,'当代广场旁边')";
            sql[1] = "Insert into Client_POPDB_property_value (Client_ID, POPDB_ID, Property_ID, Property_value) values (93 ,93 ,348 ,'紫丁香大饭店旁边')";
            (Application.Current as App).db.executeBatch(sql);

Step3:when i execute the red sql will have following Exception:

unrecognized token: "'紫丁香大"

   at SQLiteClient.SQLiteCommand.Prepare()
   at SQLiteClient.SQLiteCommand.ExecuteNonQuery()
   at POPexecution.Helper.DBHelper.executeBatch(String[] updateSQLs)
   at POPexecution.Login.imageLogin_Tap(Object sender, GestureEventArgs e)
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)