Пример #1
0
        public static int BindText(Sqlite3Statement stmt, int index, string val, int n, IntPtr free)
        {
#if USE_WP8_NATIVE_SQLITE
            return(Sqlite3.sqlite3_bind_text(stmt, index, val, n));
#elif USE_SQLITEPCL_RAW
            return(Sqlite3.sqlite3_bind_text(stmt, index, val));
#else
            return(Sqlite3.sqlite3_bind_text(stmt, index, val, n, null));
#endif
        }
        private void BindData(Sqlite3Statement statement, params object[] parameters)
        {
            if (parameters != null)
            {
                for (int i = 1; i <= parameters.Length; i++)
                {
                    object o = parameters[i - 1];
                    if (o == null)
                    {
                        Sqlite3.sqlite3_bind_null(statement, i);
                        continue;
                    }

                    var type = o.GetType();
                    var dt   = o as DateTime?;
                    if (dt.HasValue)
                    {
                        string ticks = dt.Value.Ticks.ToString();
                        Sqlite3.sqlite3_bind_text(statement, i, ticks);
                    }
                    else if (type == typeof(string))
                    {
                        Sqlite3.sqlite3_bind_text(statement, i, (string)o);
                    }
                    else if ((typeof(Int32) == type) ||
                             (typeof(Boolean) == type) ||
                             (typeof(Byte) == type) ||
                             (typeof(UInt16) == type) ||
                             (typeof(Int16) == type) ||
                             (typeof(sbyte) == type) ||
                             (typeof(Int64) == type) ||
                             (typeof(long) == type) ||
                             (typeof(UInt32) == type))
                    {
                        Sqlite3.sqlite3_bind_int64(statement, i, (Int64)Convert.ChangeType(o, typeof(Int64)));
                    }
                    else if ((typeof(double) == type) ||
                             (typeof(float) == type) ||
                             (typeof(decimal) == type))
                    {
                        Sqlite3.sqlite3_bind_double(statement, i, (double)o);
                    }
                    else if (type == typeof(byte[]))
                    {
                        Sqlite3.sqlite3_bind_blob(statement, i, (byte[])o);
                    }
                }
            }
        }
Пример #3
0
 public static int BindStringUTF8(Sqlite3Statement stmt, int index, string val, int n, IntPtr free)
 {
     return(Sqlite3.sqlite3_bind_text(stmt, index, val));
 }