本文整理汇总了C#中System.Data.Odbc.ODBC32类的典型用法代码示例。如果您正苦于以下问题:C# ODBC32类的具体用法?C# ODBC32怎么用?C# ODBC32使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODBC32类属于System.Data.Odbc命名空间,在下文中一共展示了ODBC32类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OdbcHandle
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);
}
}
示例2: SQLBindCol
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);
示例3: OdbcHandle
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);
}
}
示例4: MarshalToManaged
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;
}
示例5: SQLBindParameter
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);
示例6: CreateException
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;
}
示例7: TypeMap
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;
}
示例8: CreateException
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);
}
示例9: BindParameter
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;
}
示例10: FreeKeyInfoStatementHandle
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;
}
}
}
示例11: SetConnectionAttribute2
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;
}
示例12: GetInfo1
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;
}
示例13: FailedToGetDescriptorHandle
static internal Exception FailedToGetDescriptorHandle(ODBC32.RetCode retcode) {
return ADP.DataAdapter(Res.GetString(Res.Odbc_FailedToGetDescriptorHandle, ODBC32.RetcodeToString(retcode)));
}
示例14: CantAllocateEnvironmentHandle
static internal Exception CantAllocateEnvironmentHandle(ODBC32.RetCode retcode) {
return ADP.DataAdapter(Res.GetString(Res.Odbc_CantAllocateEnvironmentHandle, ODBC32.RetcodeToString(retcode)));
}
示例15: TypeMap
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;
}