Ejemplo n.º 1
0
        void BindParam(IDataParameter param)
        {
            NativeParameter nParam = (NativeParameter)param;

            if (nParam.Index == -1)
            {
                BindIndex(nParam);
            }

            int code = 0;

            switch (nParam.type)
            {
            case DbType.AnsiStringFixedLength:
                code = sqlite3_bind_text(Statement, nParam.Index, nParam.StringPtr,
                                         nParam.StringCount - 1, IntPtr.Zero);
                break;

            case DbType.UInt16:
                code = sqlite3_bind_int(Statement, nParam.Index, nParam.U16Value);
                break;

            case DbType.Byte:
                code = sqlite3_bind_int(Statement, nParam.Index, nParam.U8Value);
                break;

            case DbType.Boolean:
                code = sqlite3_bind_int(Statement, nParam.Index, nParam.BoolValue ? 1 : 0);
                break;
            }
            if (code > 0)
            {
                throw new NativeException(code);
            }
        }
Ejemplo n.º 2
0
        public override IDataParameter CreateParam(string paramName, DbType type)
        {
            IDataParameter param = new NativeParameter();

            param.ParameterName = paramName;
            param.DbType        = type;
            return(param);
        }
Ejemplo n.º 3
0
 void BindIndex(NativeParameter nParam)
 {
     byte[] name = NativeUtils.MakeUTF8(nParam.ParameterName);
     nParam.Index = sqlite3_bind_parameter_index(Statement, name);
 }