static internal extern /*SQLRETURN*/ODBC32.RetCode SQLBindCol( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLUSMALLINT*/UInt16 ColumnNumber, /*SQLSMALLINT*/ODBC32.SQL_C TargetType, /*SQLPOINTER*/IntPtr TargetValue, /*SQLLEN*/IntPtr BufferLength, /*SQLLEN* */IntPtr StrLen_or_Ind);
internal OdbcHandle(OdbcStatementHandle parentHandle, ODBC32.SQL_ATTR attribute) : base(IntPtr.Zero, true) { ODBC32.RetCode code; this._handleType = ODBC32.SQL_HANDLE.DESC; bool success = false; RuntimeHelpers.PrepareConstrainedRegions(); try { int num; parentHandle.DangerousAddRef(ref success); code = parentHandle.GetStatementAttribute(attribute, out this.handle, out num); } finally { if (success) { if (IntPtr.Zero != base.handle) { this._parentHandle = parentHandle; } else { parentHandle.DangerousRelease(); } } } if (ADP.PtrZero == base.handle) { throw ODBC.FailedToGetDescriptorHandle(code); } }
internal Exception HandleErrorNoThrow(OdbcHandle hrHandle, ODBC32.RetCode retcode) { switch (retcode) { case ODBC32.RetCode.SUCCESS: break; case ODBC32.RetCode.SUCCESS_WITH_INFO: if (this.infoMessageEventHandler != null) { OdbcErrorCollection errors = ODBC32.GetDiagErrors(null, hrHandle, retcode); errors.SetSource(this.Driver); this.OnInfoMessage(new OdbcInfoMessageEventArgs(errors)); } break; default: { OdbcException innerException = OdbcException.CreateException(ODBC32.GetDiagErrors(null, hrHandle, retcode), retcode); if (innerException != null) { innerException.Errors.SetSource(this.Driver); } this.ConnectionIsAlive(innerException); return(innerException); } } return(null); }
// non-throwing HandleError internal Exception HandleErrorNoThrow(OdbcHandle hrHandle, ODBC32.RetCode retcode) { Debug.Assert(retcode != ODBC32.RetCode.INVALID_HANDLE, "retcode must never be ODBC32.RetCode.INVALID_HANDLE"); switch (retcode) { case ODBC32.RetCode.SUCCESS: break; case ODBC32.RetCode.SUCCESS_WITH_INFO: { //Optimize to only create the event objects and obtain error info if //the user is really interested in retriveing the events... if (_infoMessageEventHandler != null) { OdbcErrorCollection errors = ODBC32.GetDiagErrors(null, hrHandle, retcode); errors.SetSource(this.Driver); OnInfoMessage(new OdbcInfoMessageEventArgs(errors)); } break; } default: OdbcException e = OdbcException.CreateException(ODBC32.GetDiagErrors(null, hrHandle, retcode), retcode); if (e != null) { e.Errors.SetSource(this.Driver); } ConnectionIsAlive(e); // this will close and throw if the connection is dead return((Exception)e); } return(null); }
protected OdbcHandle(ODBC32.SQL_HANDLE handleType, OdbcHandle parentHandle) : base(IntPtr.Zero, true) { _handleType = handleType; bool mustRelease = false; ODBC32.RetCode retcode = ODBC32.RetCode.SUCCESS; // using ConstrainedRegions to make the native ODBC call and AddRef the parent RuntimeHelpers.PrepareConstrainedRegions(); try { // validate handleType switch(handleType) { case ODBC32.SQL_HANDLE.ENV: Debug.Assert(null == parentHandle, "did not expect a parent handle"); retcode = UnsafeNativeMethods.SQLAllocHandle(handleType, IntPtr.Zero, out base.handle); break; case ODBC32.SQL_HANDLE.DBC: case ODBC32.SQL_HANDLE.STMT: // must addref before calling native so it won't be released just after Debug.Assert(null != parentHandle, "expected a parent handle"); // safehandle can't be null parentHandle.DangerousAddRef(ref mustRelease); retcode = UnsafeNativeMethods.SQLAllocHandle(handleType, parentHandle, out base.handle); break; // case ODBC32.SQL_HANDLE.DESC: default: Debug.Assert(false, "unexpected handleType"); break; } } finally { if (mustRelease) { switch(handleType) { case ODBC32.SQL_HANDLE.DBC: case ODBC32.SQL_HANDLE.STMT: if (IntPtr.Zero != base.handle) { // must assign _parentHandle after a handle is actually created // since ReleaseHandle will only call DangerousRelease if a handle exists _parentHandle = parentHandle; } else { // without a handle, ReleaseHandle may not be called parentHandle.DangerousRelease(); } break; } } } Bid.TraceSqlReturn("<odbc.SQLAllocHandle|API|ODBC|RET> %08X{SQLRETURN}\n", retcode); if((ADP.PtrZero == base.handle) || (ODBC32.RetCode.SUCCESS != retcode)) { // throw ODBC.CantAllocateEnvironmentHandle(retcode); } }
internal object MarshalToManaged(int offset, ODBC32.SQL_C sqlctype, int cb) { switch (sqlctype) { case ODBC32.SQL_C.SLONG: return base.ReadInt32(offset); case ODBC32.SQL_C.SSHORT: return base.ReadInt16(offset); case ODBC32.SQL_C.SBIGINT: return base.ReadInt64(offset); case ODBC32.SQL_C.UTINYINT: return base.ReadByte(offset); case ODBC32.SQL_C.GUID: return base.ReadGuid(offset); case ODBC32.SQL_C.WCHAR: if (cb != -3) { cb = Math.Min((int) (cb / 2), (int) ((base.Length - 2) / 2)); return base.PtrToStringUni(offset, cb); } return base.PtrToStringUni(offset); case ODBC32.SQL_C.BIT: return (base.ReadByte(offset) != 0); case ODBC32.SQL_C.BINARY: case ODBC32.SQL_C.CHAR: cb = Math.Min(cb, base.Length); return base.ReadBytes(offset, cb); case ODBC32.SQL_C.NUMERIC: return base.ReadNumeric(offset); case ODBC32.SQL_C.REAL: return base.ReadSingle(offset); case ODBC32.SQL_C.DOUBLE: return base.ReadDouble(offset); case ODBC32.SQL_C.TYPE_DATE: return base.ReadDate(offset); case ODBC32.SQL_C.TYPE_TIME: return base.ReadTime(offset); case ODBC32.SQL_C.TYPE_TIMESTAMP: return base.ReadDateTime(offset); } return null; }
static internal extern /*SQLRETURN*/ODBC32.RetCode SQLBindParameter( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLUSMALLINT*/UInt16 ParameterNumber, /*SQLSMALLINT*/Int16 ParamDirection, /*SQLSMALLINT*/ODBC32.SQL_C SQLCType, /*SQLSMALLINT*/Int16 SQLType, /*SQLULEN*/IntPtr cbColDef, /*SQLSMALLINT*/IntPtr ibScale, /*SQLPOINTER*/HandleRef rgbValue, /*SQLLEN*/IntPtr BufferLength, /*SQLLEN* */HandleRef StrLen_or_Ind);
ODBC32.RETCODE _retcode; // DO NOT REMOVE! only needed for serialization purposes, because Everett had it. static internal OdbcException CreateException(OdbcErrorCollection errors, ODBC32.RetCode retcode) { StringBuilder builder = new StringBuilder(); foreach (OdbcError error in errors) { if (builder.Length > 0) { builder.Append(Environment.NewLine); } builder.Append(Res.GetString(Res.Odbc_ExceptionMessage, ODBC32.RetcodeToString(retcode), error.SQLState, error.Message)); // MDAC 68337 } OdbcException exception = new OdbcException(builder.ToString(), errors); return exception; }
private TypeMap(OdbcType odbcType, DbType dbType, Type type, ODBC32.SQL_TYPE sql_type, ODBC32.SQL_C sql_c, ODBC32.SQL_C param_sql_c, int bsize, int csize, bool signType) { this._odbcType = odbcType; this._dbType = dbType; this._type = type; this._sql_type = sql_type; this._sql_c = sql_c; this._param_sql_c = param_sql_c; this._bufferSize = bsize; this._columnSize = csize; this._signType = signType; }
internal static OdbcException CreateException(OdbcErrorCollection errors, ODBC32.RetCode retcode) { StringBuilder builder = new StringBuilder(); foreach (OdbcError error in errors) { if (builder.Length > 0) { builder.Append(Environment.NewLine); } builder.Append(Res.GetString("Odbc_ExceptionMessage", new object[] { ODBC32.RetcodeToString(retcode), error.SQLState, error.Message })); } return new OdbcException(builder.ToString(), errors); }
internal static OdbcException CreateException(OdbcErrorCollection errors, ODBC32.RetCode retcode) { StringBuilder builder = new StringBuilder(); foreach (OdbcError error in errors) { if (builder.Length > 0) { builder.Append(Environment.NewLine); } builder.Append(Res.GetString("Odbc_ExceptionMessage", new object[] { ODBC32.RetcodeToString(retcode), error.SQLState, error.Message })); } return(new OdbcException(builder.ToString(), errors)); }
internal ODBC32.RetCode BindParameter(short ordinal, short parameterDirection, ODBC32.SQL_C sqlctype, ODBC32.SQL_TYPE sqltype, IntPtr cchSize, IntPtr scale, HandleRef buffer, IntPtr bufferLength, HandleRef intbuffer) { ODBC32.RetCode retcode = UnsafeNativeMethods.SQLBindParameter(this, checked((ushort)ordinal), // Parameter Number parameterDirection, // InputOutputType sqlctype, // ValueType checked((short)sqltype), // ParameterType cchSize, // ColumnSize scale, // DecimalDigits buffer, // ParameterValuePtr bufferLength, // BufferLength intbuffer); // StrLen_or_IndPtr ODBC.TraceODBC(3, "SQLBindParameter", retcode); return retcode; }
protected OdbcHandle(ODBC32.SQL_HANDLE handleType, OdbcHandle parentHandle) : base(IntPtr.Zero, true) { this._handleType = handleType; bool success = false; ODBC32.RetCode sUCCESS = ODBC32.RetCode.SUCCESS; RuntimeHelpers.PrepareConstrainedRegions(); try { switch (handleType) { case ODBC32.SQL_HANDLE.ENV: sUCCESS = UnsafeNativeMethods.SQLAllocHandle(handleType, IntPtr.Zero, out this.handle); goto Label_0099; case ODBC32.SQL_HANDLE.DBC: case ODBC32.SQL_HANDLE.STMT: parentHandle.DangerousAddRef(ref success); sUCCESS = UnsafeNativeMethods.SQLAllocHandle(handleType, parentHandle, out this.handle); goto Label_0099; } } finally { if (success) { switch (handleType) { case ODBC32.SQL_HANDLE.DBC: case ODBC32.SQL_HANDLE.STMT: if (!(IntPtr.Zero != base.handle)) { goto Label_0092; } this._parentHandle = parentHandle; break; } } goto Label_0098; Label_0092: parentHandle.DangerousRelease(); Label_0098:; } Label_0099: Bid.TraceSqlReturn("<odbc.SQLAllocHandle|API|ODBC|RET> %08X{SQLRETURN}\n", sUCCESS); if ((ADP.PtrZero == base.handle) || (sUCCESS != ODBC32.RetCode.SUCCESS)) { throw ODBC.CantAllocateEnvironmentHandle(sUCCESS); } }
internal static OdbcException CreateException(OdbcErrorCollection errors, ODBC32.RetCode retcode) { StringBuilder builder = new StringBuilder(); foreach (OdbcError error in errors) { if (builder.Length > 0) { builder.Append(Environment.NewLine); } builder.Append(SR.GetString(SR.Odbc_ExceptionMessage, ODBC32.RetcodeToString(retcode), error.SQLState, error.Message)); // MDAC 68337 } OdbcException exception = new OdbcException(builder.ToString(), errors); return(exception); }
internal void FreeKeyInfoStatementHandle(ODBC32.STMT stmt) { OdbcStatementHandle handle = this._keyinfostmt; if (handle != null) { try { handle.FreeStatement(stmt); } catch (Exception exception) { if (ADP.IsCatchableExceptionType(exception)) { this._keyinfostmt = null; handle.Dispose(); } throw; } } }
internal static Exception CantAllocateEnvironmentHandle(ODBC32.RetCode retcode) { return(ADP.DataAdapter(Res.GetString("Odbc_CantAllocateEnvironmentHandle", new object[] { ODBC32.RetcodeToString(retcode) }))); }
internal static Exception FailedToGetDescriptorHandle(ODBC32.RetCode retcode) { return(ADP.DataAdapter(SR.GetString(SR.Odbc_FailedToGetDescriptorHandle, ODBC32.RetcodeToString(retcode)))); }
internal bool TestTypeSupport (ODBC32.SQL_TYPE sqltype){ ODBC32.SQL_CONVERT sqlconvert; ODBC32.SQL_CVT sqlcvt; // we need to convert the sqltype to sqlconvert and sqlcvt first // switch (sqltype) { case ODBC32.SQL_TYPE.NUMERIC: { sqlconvert = ODBC32.SQL_CONVERT.NUMERIC; sqlcvt = ODBC32.SQL_CVT.NUMERIC; break; } case ODBC32.SQL_TYPE.WCHAR: { sqlconvert = ODBC32.SQL_CONVERT.CHAR; sqlcvt = ODBC32.SQL_CVT.WCHAR; break; } case ODBC32.SQL_TYPE.WVARCHAR: { sqlconvert = ODBC32.SQL_CONVERT.VARCHAR; sqlcvt = ODBC32.SQL_CVT.WVARCHAR; break; } case ODBC32.SQL_TYPE.WLONGVARCHAR: { sqlconvert = ODBC32.SQL_CONVERT.LONGVARCHAR; sqlcvt = ODBC32.SQL_CVT.WLONGVARCHAR; break; } default: Debug.Assert(false, "Testing that sqltype is currently not supported"); return false; } // now we can check if we have already tested that type // if not we need to do so if (0 == (ProviderInfo.TestedSQLTypes & (int)sqlcvt)) { int flags; flags = GetInfoInt32Unhandled((ODBC32.SQL_INFO)sqlconvert); flags = flags & (int)sqlcvt; ProviderInfo.TestedSQLTypes |= (int)sqlcvt; ProviderInfo.SupportedSQLTypes |= flags; } // now check if the type is supported and return the result // return (0 != (ProviderInfo.SupportedSQLTypes & (int)sqlcvt)); }
internal ODBC32.RetCode GetConnectionAttribute(ODBC32.SQL_ATTR attribute, byte[] buffer, out int cbActual) { ODBC32.RetCode retcode = UnsafeNativeMethods.SQLGetConnectAttrW(this, attribute, buffer, buffer.Length, out cbActual); Bid.Trace("<odbc.SQLGetConnectAttr|ODBC> SQLRETURN=%d, Attribute=%d, BufferLength=%d, StringLength=%d\n", (int)retcode, (int)attribute, buffer.Length, (int)cbActual); return retcode; }
static internal Exception CantAllocateEnvironmentHandle(ODBC32.RetCode retcode) { return ADP.DataAdapter(Res.GetString(Res.Odbc_CantAllocateEnvironmentHandle, ODBC32.RetcodeToString(retcode))); }
internal readonly bool _signType; // this type may be has signature information private TypeMap(OdbcType odbcType, DbType dbType, Type type, ODBC32.SQL_TYPE sql_type, ODBC32.SQL_C sql_c, ODBC32.SQL_C param_sql_c, int bsize, int csize, bool signType) { _odbcType = odbcType; _dbType = dbType; _type = type; _sql_type = sql_type; _sql_c = sql_c; _param_sql_c = param_sql_c; // alternative sql_c type for parameters _bufferSize = bsize; _columnSize = csize; _signType = signType; }
static internal void TraceODBC(int level, string method, ODBC32.RetCode retcode) { Bid.TraceSqlReturn("<odbc|API|ODBC|RET> %08X{SQLRETURN}, method=%ls\n", retcode, method); }
internal ODBC32.RetCode SetConnectionAttribute3(ODBC32.SQL_ATTR attribute, string buffer, Int32 length) { ODBC32.RetCode retcode = UnsafeNativeMethods.SQLSetConnectAttrW(this, attribute, buffer, length); Bid.Trace("<odbc.SQLSetConnectAttr|ODBC> SQLRETURN=%d, Attribute=%d, BufferLength=%d\n", (int)retcode, (int)attribute, buffer.Length); return retcode; }
internal ODBC32.RetCode SetConnectionAttribute2(ODBC32.SQL_ATTR attribute, IntPtr value, Int32 length) { ODBC32.RetCode retcode = UnsafeNativeMethods.SQLSetConnectAttrW(this, attribute, value, length); ODBC.TraceODBC(3, "SQLSetConnectAttrW", retcode); return retcode; }
internal ODBC32.RetCode GetInfo1(ODBC32.SQL_INFO info, byte[] buffer) { ODBC32.RetCode retcode = UnsafeNativeMethods.SQLGetInfoW(this, info, buffer, checked((short)buffer.Length), ADP.PtrZero); Bid.Trace("<odbc.SQLGetInfo|ODBC> SQLRETURN=%d, InfoType=%d, BufferLength=%d\n", (int)retcode, (int)info, buffer.Length); return retcode; }
internal ODBC32.RetCode GetInfo2(ODBC32.SQL_INFO info, byte[] buffer, out short cbActual) { ODBC32.RetCode retcode = UnsafeNativeMethods.SQLGetInfoW(this, info, buffer, checked((short)buffer.Length), out cbActual); Bid.Trace("<odbc.SQLGetInfo|ODBC> SQLRETURN=%d, InfoType=%d, BufferLength=%d, StringLength=%d\n", (int)retcode, (int)info, buffer.Length, (int)cbActual); return retcode; }
internal ODBC32.RetCode GetFunctions(ODBC32.SQL_API fFunction, out Int16 fExists) { ODBC32.RetCode retcode = UnsafeNativeMethods.SQLGetFunctions(this, fFunction, out fExists); ODBC.TraceODBC(3, "SQLGetFunctions", retcode); return retcode; }
internal static Exception CantEnableConnectionpooling(ODBC32.RetCode retcode) { return(ADP.DataAdapter(Res.GetString("Odbc_CantEnableConnectionpooling", new object[] { ODBC32.RetcodeToString(retcode) }))); }
internal static Exception FailedToGetDescriptorHandle(ODBC32.RetCode retcode) { return(ADP.DataAdapter(Res.GetString("Odbc_FailedToGetDescriptorHandle", new object[] { ODBC32.RetcodeToString(retcode) }))); }
internal bool TestRestrictedSqlBindType (ODBC32.SQL_TYPE sqltype){ ODBC32.SQL_CVT sqlcvt; switch (sqltype) { case ODBC32.SQL_TYPE.NUMERIC: { sqlcvt = ODBC32.SQL_CVT.NUMERIC; break; } case ODBC32.SQL_TYPE.DECIMAL: { sqlcvt = ODBC32.SQL_CVT.DECIMAL; break; } default: Debug.Assert(false, "Testing that sqltype is currently not supported"); return false; } return (0 != (ProviderInfo.RestrictedSQLBindTypes & (int)sqlcvt)); }
static internal Exception UnknownSQLType(ODBC32.SQL_TYPE sqltype) { return ADP.Argument(Res.GetString(Res.Odbc_UnknownSQLType, sqltype.ToString())); }
internal void MarshalToNative(int offset, object value, ODBC32.SQL_C sqlctype, int sizeorprecision, int valueOffset) { ODBC32.SQL_C sql_c = sqlctype; if (sql_c <= ODBC32.SQL_C.SSHORT) { if (sql_c != ODBC32.SQL_C.UTINYINT) { switch (sql_c) { case ODBC32.SQL_C.SLONG: base.WriteInt32(offset, (int) value); return; case ODBC32.SQL_C.SSHORT: base.WriteInt16(offset, (short) value); return; case ODBC32.SQL_C.SBIGINT: base.WriteInt64(offset, (long) value); return; } } else { base.WriteByte(offset, (byte) value); } } else if (sql_c <= ODBC32.SQL_C.NUMERIC) { switch (sql_c) { case ODBC32.SQL_C.GUID: base.WriteGuid(offset, (Guid) value); return; case ~(ODBC32.SQL_C.CHAR | ODBC32.SQL_C.DOUBLE): case ~ODBC32.SQL_C.DOUBLE: case ((ODBC32.SQL_C) (-1)): case ((ODBC32.SQL_C) 0): return; case ODBC32.SQL_C.WCHAR: int num; char[] chArray; if (value is string) { num = Math.Max(0, ((string) value).Length - valueOffset); if ((sizeorprecision > 0) && (sizeorprecision < num)) { num = sizeorprecision; } chArray = ((string) value).ToCharArray(valueOffset, num); base.WriteCharArray(offset, chArray, 0, chArray.Length); base.WriteInt16(offset + (chArray.Length * 2), 0); return; } num = Math.Max(0, ((char[]) value).Length - valueOffset); if ((sizeorprecision > 0) && (sizeorprecision < num)) { num = sizeorprecision; } chArray = (char[]) value; base.WriteCharArray(offset, chArray, valueOffset, num); base.WriteInt16(offset + (chArray.Length * 2), 0); return; case ODBC32.SQL_C.BIT: base.WriteByte(offset, ((bool) value) ? ((byte) 1) : ((byte) 0)); return; case ODBC32.SQL_C.BINARY: case ODBC32.SQL_C.CHAR: { byte[] source = (byte[]) value; int length = source.Length; length -= valueOffset; if ((sizeorprecision > 0) && (sizeorprecision < length)) { length = sizeorprecision; } base.WriteBytes(offset, source, valueOffset, length); return; } case ODBC32.SQL_C.NUMERIC: base.WriteNumeric(offset, (decimal) value, (byte) sizeorprecision); return; } } else { switch (sql_c) { case ODBC32.SQL_C.REAL: base.WriteSingle(offset, (float) value); return; case ODBC32.SQL_C.DOUBLE: base.WriteDouble(offset, (double) value); return; case ODBC32.SQL_C.TYPE_DATE: base.WriteDate(offset, (DateTime) value); return; case ODBC32.SQL_C.TYPE_TIME: base.WriteTime(offset, (TimeSpan) value); return; case ODBC32.SQL_C.TYPE_TIMESTAMP: this.WriteODBCDateTime(offset, (DateTime) value); return; default: return; } } }
static internal Exception CantEnableConnectionpooling(ODBC32.RetCode retcode) { return ADP.DataAdapter(Res.GetString(Res.Odbc_CantEnableConnectionpooling, ODBC32.RetcodeToString(retcode))); }
static internal Exception FailedToGetDescriptorHandle(ODBC32.RetCode retcode) { return ADP.DataAdapter(Res.GetString(Res.Odbc_FailedToGetDescriptorHandle, ODBC32.RetcodeToString(retcode))); }
static internal TypeMap FromSqlType(ODBC32.SQL_TYPE sqltype) { switch(sqltype) { case ODBC32.SQL_TYPE.CHAR: return _Char; case ODBC32.SQL_TYPE.VARCHAR: return _VarChar; case ODBC32.SQL_TYPE.LONGVARCHAR: return _Text; case ODBC32.SQL_TYPE.WCHAR: return _NChar; case ODBC32.SQL_TYPE.WVARCHAR: return _NVarChar; case ODBC32.SQL_TYPE.WLONGVARCHAR: return _NText; case ODBC32.SQL_TYPE.DECIMAL: return _Decimal; case ODBC32.SQL_TYPE.NUMERIC: return _Numeric; case ODBC32.SQL_TYPE.SMALLINT: return _SmallInt; case ODBC32.SQL_TYPE.INTEGER: return _Int; case ODBC32.SQL_TYPE.REAL: return _Real; case ODBC32.SQL_TYPE.FLOAT: return _Double; case ODBC32.SQL_TYPE.DOUBLE: return _Double; case ODBC32.SQL_TYPE.BIT: return _Bit; case ODBC32.SQL_TYPE.TINYINT: return _TinyInt; case ODBC32.SQL_TYPE.BIGINT: return _BigInt; case ODBC32.SQL_TYPE.BINARY: return _Binary; case ODBC32.SQL_TYPE.VARBINARY: return _VarBinary; case ODBC32.SQL_TYPE.LONGVARBINARY: return _Image; case ODBC32.SQL_TYPE.TYPE_DATE: return _Date; case ODBC32.SQL_TYPE.TYPE_TIME: return _Time; case ODBC32.SQL_TYPE.TIMESTAMP: case ODBC32.SQL_TYPE.TYPE_TIMESTAMP: return _DateTime; case ODBC32.SQL_TYPE.GUID: return _UniqueId; case ODBC32.SQL_TYPE.SS_VARIANT: return _Variant; case ODBC32.SQL_TYPE.SS_UDT: return _UDT; case ODBC32.SQL_TYPE.SS_XML: return _XML; case ODBC32.SQL_TYPE.SS_UTCDATETIME: case ODBC32.SQL_TYPE.SS_TIME_EX: throw ODBC.UnknownSQLType(sqltype); default: throw ODBC.UnknownSQLType(sqltype); } }
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 SchemaFunctionName(string schemaName, ODBC32.SQL_API odbcFunction) { _schemaName = schemaName; _odbcFunction = odbcFunction; }
internal static Exception CantEnableConnectionpooling(ODBC32.RetCode retcode) { return(ADP.DataAdapter(SR.GetString(SR.Odbc_CantEnableConnectionpooling, ODBC32.RetcodeToString(retcode)))); }
internal ODBC32.RetCode SetConnectionAttribute4(ODBC32.SQL_ATTR attribute, System.Transactions.IDtcTransaction transaction, Int32 length) { ODBC32.RetCode retcode = UnsafeNativeMethods.SQLSetConnectAttrW(this, attribute, transaction, length); ODBC.TraceODBC(3, "SQLSetConnectAttrW", retcode); return retcode; }
internal static Exception CantAllocateEnvironmentHandle(ODBC32.RetCode retcode) { return(ADP.DataAdapter(SR.GetString(SR.Odbc_CantAllocateEnvironmentHandle, ODBC32.RetcodeToString(retcode)))); }