Esempio n. 1
0
        internal void SetInputValue(object value, ODBC32.SQL_C sql_c_type, int cbsize, int sizeorprecision, int offset, CNativeBuffer parameterBuffer)
        {
            if ((ParameterDirection.Input != this._internalDirection) && (ParameterDirection.InputOutput != this._internalDirection))
            {
                this._internalValue = null;
                parameterBuffer.WriteIntPtr(this._preparedIntOffset, (IntPtr)(-1));
            }
            else if (value == null)
            {
                parameterBuffer.WriteIntPtr(this._preparedIntOffset, (IntPtr)(-5));
            }
            else if (Convert.IsDBNull(value))
            {
                parameterBuffer.WriteIntPtr(this._preparedIntOffset, (IntPtr)(-1));
            }
            else
            {
                switch (sql_c_type)
                {
                case ODBC32.SQL_C.WCHAR:
                case ODBC32.SQL_C.BINARY:
                case ODBC32.SQL_C.CHAR:
                    parameterBuffer.WriteIntPtr(this._preparedIntOffset, (IntPtr)cbsize);
                    break;

                default:
                    parameterBuffer.WriteIntPtr(this._preparedIntOffset, IntPtr.Zero);
                    break;
                }
                parameterBuffer.MarshalToNative(this._preparedValueOffset, value, sql_c_type, sizeorprecision, offset);
            }
        }
Esempio n. 2
0
        internal void SetInputValue(int size, object value, byte precision, CNativeBuffer buffer, CNativeBuffer intbuffer)   //Handle any input params
        {
#if DEBUG
            if (AdapterSwitches.DataValue.TraceVerbose)
            {
                Debug.WriteLine("SQLBindParameter:" + _typemap._odbcType.ToString("G") + " " + _bindtype._odbcType.ToString("G") + "(" + size + ")=" + ADP.ValueToString(value));
            }
#endif
            if ((ODBC32.SQL_PARAM.INPUT == _sqldirection) || (ODBC32.SQL_PARAM.INPUT_OUTPUT == _sqldirection))
            {
                ODBC32.SQL_C sql_c_type;
                sql_c_type = (_parent.Connection.OdbcMajorVersion >= 3) ? _bindtype._sql_c : _bindtype._param_sql_c;

                //Note: (lang) "null" means to use the servers default (not DBNull).
                //We probably should just not have bound this parameter, period, but that
                //would mess up the users question marks, etc...
                if ((null == value))
                {
                    Marshal.WriteInt32(intbuffer.Ptr, ODBC32.SQL_DEFAULT_PARAM);
                }
                else if (Convert.IsDBNull(value))
                {
                    Marshal.WriteInt32(intbuffer.Ptr, ODBC32.SQL_NULL_DATA);
                }
                else
                {
                    // Clear previous NULL_DATA status
                    Marshal.WriteInt32(intbuffer.Ptr, 0);
                    switch (sql_c_type)
                    {
                    case ODBC32.SQL_C.CHAR:
                    case ODBC32.SQL_C.WCHAR:
                    case ODBC32.SQL_C.BINARY:
                        //StrLen_or_IndPtr is ignored except for Character or Binary or data.
                        Marshal.WriteInt32(intbuffer.Ptr, size);
                        break;
                    }

                    //Place the input param value into the native buffer
                    buffer.MarshalToNative(value, sql_c_type, precision);
                }
            }
            else
            {
                // always set ouput only and return value parameter values to null when executing
                Value = null;

                //Always initialize the intbuffer (for output params).  Since we need to know
                //if/when the parameters are available for output. (ie: when is the buffer valid...)
                //if (_sqldirection != ODBC32.SQL_PARAM.INPUT)
                Marshal.WriteInt32(intbuffer.Ptr, ODBC32.SQL_NULL_DATA);
            }
        }
Esempio n. 3
0
        internal void SetInputValue(object value, ODBC32.SQL_C sql_c_type, int cbsize, int sizeorprecision, int offset, CNativeBuffer parameterBuffer)
        { //Handle any input params
            if ((ParameterDirection.Input == _internalDirection) || (ParameterDirection.InputOutput == _internalDirection))
            {
                //Note: (lang) "null" means to use the servers default (not DBNull).
                //We probably should just not have bound this parameter, period, but that
                //would mess up the users question marks, etc...
                if ((null == value))
                {
                    parameterBuffer.WriteIntPtr(_preparedIntOffset, (IntPtr)ODBC32.SQL_DEFAULT_PARAM);
                }
                else if (Convert.IsDBNull(value))
                {
                    parameterBuffer.WriteIntPtr(_preparedIntOffset, (IntPtr)ODBC32.SQL_NULL_DATA);
                }
                else
                {
                    switch (sql_c_type)
                    {
                    case ODBC32.SQL_C.CHAR:
                    case ODBC32.SQL_C.WCHAR:
                    case ODBC32.SQL_C.BINARY:
                        //StrLen_or_IndPtr is ignored except for Character or Binary or data.
                        parameterBuffer.WriteIntPtr(_preparedIntOffset, (IntPtr)cbsize);
                        break;

                    default:
                        parameterBuffer.WriteIntPtr(_preparedIntOffset, IntPtr.Zero);
                        break;
                    }

                    //Place the input param value into the native buffer
                    parameterBuffer.MarshalToNative(_preparedValueOffset, value, sql_c_type, sizeorprecision, offset);
                }
            }
            else
            {
                // always set ouput only and return value parameter values to null when executing
                _internalValue = null;

                //Always initialize the intbuffer (for output params).  Since we need to know
                //if/when the parameters are available for output. (ie: when is the buffer valid...)
                //if (_sqldirection != ODBC32.SQL_PARAM.INPUT)
                parameterBuffer.WriteIntPtr(_preparedIntOffset, (IntPtr)ODBC32.SQL_NULL_DATA);
            }
        }
        internal void SetInputValue(object value, ODBC32.SQL_C sql_c_type, int cbsize, int sizeorprecision, int offset, CNativeBuffer parameterBuffer) { //Handle any input params
            if((ParameterDirection.Input == _internalDirection) || (ParameterDirection.InputOutput == _internalDirection)) {
                //Note: (lang) "null" means to use the servers default (not DBNull).
                //We probably should just not have bound this parameter, period, but that
                //would mess up the users question marks, etc...
                if((null == value)) {
                    parameterBuffer.WriteIntPtr(_preparedIntOffset, (IntPtr)ODBC32.SQL_DEFAULT_PARAM);
                }
                else if(Convert.IsDBNull(value)) {
                    parameterBuffer.WriteIntPtr(_preparedIntOffset, (IntPtr)ODBC32.SQL_NULL_DATA);
                }
                else {
                    switch(sql_c_type) {
                    case ODBC32.SQL_C.CHAR:
                    case ODBC32.SQL_C.WCHAR:
                    case ODBC32.SQL_C.BINARY:
                        //StrLen_or_IndPtr is ignored except for Character or Binary or data.
                        parameterBuffer.WriteIntPtr(_preparedIntOffset, (IntPtr)cbsize);
                        break;
                    default:
                        parameterBuffer.WriteIntPtr(_preparedIntOffset, IntPtr.Zero);
                        break;

                    }

                    //Place the input param value into the native buffer
                    parameterBuffer.MarshalToNative(_preparedValueOffset, value, sql_c_type, sizeorprecision, offset);
                }
            }
            else {
                // always set ouput only and return value parameter values to null when executing
                _internalValue = null;

                //Always initialize the intbuffer (for output params).  Since we need to know
                //if/when the parameters are available for output. (ie: when is the buffer valid...)
                //if (_sqldirection != ODBC32.SQL_PARAM.INPUT)
                parameterBuffer.WriteIntPtr(_preparedIntOffset, (IntPtr)ODBC32.SQL_NULL_DATA);
            }
        }
        internal void SetInputValue(object value, ODBC32.SQL_C sql_c_type, int cbsize, int sizeorprecision, int offset, CNativeBuffer parameterBuffer)
        {
            if ((ParameterDirection.Input != this._internalDirection) && (ParameterDirection.InputOutput != this._internalDirection))
            {
                this._internalValue = null;
                parameterBuffer.WriteIntPtr(this._preparedIntOffset, (IntPtr) (-1));
            }
            else if (value == null)
            {
                parameterBuffer.WriteIntPtr(this._preparedIntOffset, (IntPtr) (-5));
            }
            else if (Convert.IsDBNull(value))
            {
                parameterBuffer.WriteIntPtr(this._preparedIntOffset, (IntPtr) (-1));
            }
            else
            {
                switch (sql_c_type)
                {
                    case ODBC32.SQL_C.WCHAR:
                    case ODBC32.SQL_C.BINARY:
                    case ODBC32.SQL_C.CHAR:
                        parameterBuffer.WriteIntPtr(this._preparedIntOffset, (IntPtr) cbsize);
                        break;

                    default:
                        parameterBuffer.WriteIntPtr(this._preparedIntOffset, IntPtr.Zero);
                        break;
                }
                parameterBuffer.MarshalToNative(this._preparedValueOffset, value, sql_c_type, sizeorprecision, offset);
            }
        }