1 //------------------------------------------------------------------------------ 2 // <copyright file="UnsafeNativeMethods.cs" company="Microsoft"> 3 // Copyright (c) Microsoft Corporation. All rights reserved. 4 // </copyright> 5 // <owner current="true" primary="true">Microsoft</owner> 6 // <owner current="true" primary="false">Microsoft</owner> 7 // <owner current="true" primary="false">Microsoft</owner> 8 //------------------------------------------------------------------------------ 9 10 using System; 11 #if !NO_ODBC 12 using System.Data.Odbc; 13 #endif 14 using System.Runtime.CompilerServices; 15 using System.Runtime.InteropServices; 16 using System.Security; 17 using System.Security.Permissions; 18 using System.Text; 19 using System.Runtime.ConstrainedExecution; 20 using System.Runtime.Versioning; 21 22 namespace System.Data.Common { 23 24 [SuppressUnmanagedCodeSecurityAttribute()] 25 internal static class UnsafeNativeMethods { 26 27 #if !NO_ODBC 28 // 29 // ODBC32 30 // 31 [DllImport(ExternDll.Odbc32)] 32 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] 33 [ResourceExposure(ResourceScope.None)] SQLAllocHandle( ODBC32.SQL_HANDLE HandleType, IntPtr InputHandle, out IntPtr OutputHandle)34 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLAllocHandle( 35 /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType, 36 /*SQLHANDLE*/IntPtr InputHandle, 37 /*SQLHANDLE* */out IntPtr OutputHandle); 38 39 [DllImport(ExternDll.Odbc32)] 40 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] 41 [ResourceExposure(ResourceScope.None)] SQLAllocHandle( ODBC32.SQL_HANDLE HandleType, OdbcHandle InputHandle, out IntPtr OutputHandle)42 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLAllocHandle( 43 /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType, 44 /*SQLHANDLE*/OdbcHandle InputHandle, 45 /*SQLHANDLE* */out IntPtr OutputHandle); 46 47 48 [DllImport(ExternDll.Odbc32)] 49 [ResourceExposure(ResourceScope.None)] SQLBindCol( OdbcStatementHandle StatementHandle, UInt16 ColumnNumber, ODBC32.SQL_C TargetType, HandleRef TargetValue, IntPtr BufferLength, IntPtr StrLen_or_Ind)50 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLBindCol( 51 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 52 /*SQLUSMALLINT*/UInt16 ColumnNumber, 53 /*SQLSMALLINT*/ODBC32.SQL_C TargetType, 54 /*SQLPOINTER*/HandleRef TargetValue, 55 /*SQLLEN*/IntPtr BufferLength, 56 /*SQLLEN* */IntPtr StrLen_or_Ind); 57 58 [DllImport(ExternDll.Odbc32)] 59 [ResourceExposure(ResourceScope.None)] SQLBindCol( OdbcStatementHandle StatementHandle, UInt16 ColumnNumber, ODBC32.SQL_C TargetType, IntPtr TargetValue, IntPtr BufferLength, IntPtr StrLen_or_Ind)60 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLBindCol( 61 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 62 /*SQLUSMALLINT*/UInt16 ColumnNumber, 63 /*SQLSMALLINT*/ODBC32.SQL_C TargetType, 64 /*SQLPOINTER*/IntPtr TargetValue, 65 /*SQLLEN*/IntPtr BufferLength, 66 /*SQLLEN* */IntPtr StrLen_or_Ind); 67 68 [DllImport(ExternDll.Odbc32)] 69 [ResourceExposure(ResourceScope.None)] SQLBindParameter( OdbcStatementHandle StatementHandle, UInt16 ParameterNumber, Int16 ParamDirection, ODBC32.SQL_C SQLCType, Int16 SQLType, IntPtr cbColDef, IntPtr ibScale, HandleRef rgbValue, IntPtr BufferLength, HandleRef StrLen_or_Ind)70 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLBindParameter( 71 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 72 /*SQLUSMALLINT*/UInt16 ParameterNumber, 73 /*SQLSMALLINT*/Int16 ParamDirection, 74 /*SQLSMALLINT*/ODBC32.SQL_C SQLCType, 75 /*SQLSMALLINT*/Int16 SQLType, 76 /*SQLULEN*/IntPtr cbColDef, 77 /*SQLSMALLINT*/IntPtr ibScale, 78 /*SQLPOINTER*/HandleRef rgbValue, 79 /*SQLLEN*/IntPtr BufferLength, 80 /*SQLLEN* */HandleRef StrLen_or_Ind); 81 82 [DllImport(ExternDll.Odbc32)] 83 [ResourceExposure(ResourceScope.None)] SQLCancel( OdbcStatementHandle StatementHandle)84 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLCancel( 85 /*SQLHSTMT*/OdbcStatementHandle StatementHandle); 86 87 [DllImport(ExternDll.Odbc32)] 88 [ResourceExposure(ResourceScope.None)] SQLCloseCursor( OdbcStatementHandle StatementHandle)89 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLCloseCursor( 90 /*SQLHSTMT*/OdbcStatementHandle StatementHandle); 91 92 [DllImport(ExternDll.Odbc32)] 93 [ResourceExposure(ResourceScope.None)] SQLColAttributeW( OdbcStatementHandle StatementHandle, Int16 ColumnNumber, Int16 FieldIdentifier, CNativeBuffer CharacterAttribute, Int16 BufferLength, out Int16 StringLength, out IntPtr NumericAttribute)94 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLColAttributeW ( 95 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 96 /*SQLUSMALLINT*/Int16 ColumnNumber, 97 /*SQLUSMALLINT*/Int16 FieldIdentifier, 98 /*SQLPOINTER*/CNativeBuffer CharacterAttribute, 99 /*SQLSMALLINT*/Int16 BufferLength, 100 /*SQLSMALLINT* */out Int16 StringLength, 101 /*SQLPOINTER*/out IntPtr NumericAttribute); 102 103 // note: in sql.h this is defined differently for the 64Bit platform. 104 // However, for us the code is not different for SQLPOINTER or SQLLEN ... 105 // frome sql.h: 106 // #ifdef _WIN64 107 // SQLRETURN SQL_API SQLColAttribute (SQLHSTMT StatementHandle, 108 // SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, 109 // SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength, 110 // SQLSMALLINT *StringLength, SQLLEN *NumericAttribute); 111 // #else 112 // SQLRETURN SQL_API SQLColAttribute (SQLHSTMT StatementHandle, 113 // SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, 114 // SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength, 115 // SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute); 116 // #endif 117 118 119 [DllImport(ExternDll.Odbc32)] 120 [ResourceExposure(ResourceScope.None)] SQLColumnsW( OdbcStatementHandle StatementHandle, [In, MarshalAs(UnmanagedType.LPWStr)] string CatalogName, Int16 NameLen1, [In, MarshalAs(UnmanagedType.LPWStr)] string SchemaName, Int16 NameLen2, [In, MarshalAs(UnmanagedType.LPWStr)] string TableName, Int16 NameLen3, [In, MarshalAs(UnmanagedType.LPWStr)] string ColumnName, Int16 NameLen4)121 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLColumnsW ( 122 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 123 [In, MarshalAs(UnmanagedType.LPWStr)] 124 /*SQLCHAR* */string CatalogName, 125 /*SQLSMALLINT*/Int16 NameLen1, 126 [In, MarshalAs(UnmanagedType.LPWStr)] 127 /*SQLCHAR* */string SchemaName, 128 /*SQLSMALLINT*/Int16 NameLen2, 129 [In, MarshalAs(UnmanagedType.LPWStr)] 130 /*SQLCHAR* */string TableName, 131 /*SQLSMALLINT*/Int16 NameLen3, 132 [In, MarshalAs(UnmanagedType.LPWStr)] 133 /*SQLCHAR* */string ColumnName, 134 /*SQLSMALLINT*/Int16 NameLen4); 135 136 [DllImport(ExternDll.Odbc32)] 137 [ResourceExposure(ResourceScope.None)] 138 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] SQLDisconnect( IntPtr ConnectionHandle)139 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLDisconnect( 140 /*SQLHDBC*/IntPtr ConnectionHandle); 141 142 [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)] 143 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] 144 [ResourceExposure(ResourceScope.None)] SQLDriverConnectW( OdbcConnectionHandle hdbc, IntPtr hwnd, [In, MarshalAs(UnmanagedType.LPWStr)] string connectionstring, Int16 cbConnectionstring, IntPtr connectionstringout, Int16 cbConnectionstringoutMax, out Int16 cbConnectionstringout, Int16 fDriverCompletion)145 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLDriverConnectW( 146 /*SQLHDBC*/OdbcConnectionHandle hdbc, 147 /*SQLHWND*/IntPtr hwnd, 148 [In, MarshalAs(UnmanagedType.LPWStr)] 149 /*SQLCHAR* */string connectionstring, 150 /*SQLSMALLINT*/Int16 cbConnectionstring, 151 /*SQLCHAR* */IntPtr connectionstringout, 152 /*SQLSMALLINT*/Int16 cbConnectionstringoutMax, 153 /*SQLSMALLINT* */out Int16 cbConnectionstringout, 154 /*SQLUSMALLINT*/Int16 fDriverCompletion); 155 156 [DllImport(ExternDll.Odbc32)] 157 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] 158 [ResourceExposure(ResourceScope.None)] SQLEndTran( ODBC32.SQL_HANDLE HandleType, IntPtr Handle, Int16 CompletionType)159 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLEndTran( 160 /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType, 161 /*SQLHANDLE*/IntPtr Handle, 162 /*SQLSMALLINT*/Int16 CompletionType); 163 164 [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)] 165 [ResourceExposure(ResourceScope.None)] SQLExecDirectW( OdbcStatementHandle StatementHandle, [In, MarshalAs(UnmanagedType.LPWStr)] string StatementText, Int32 TextLength)166 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLExecDirectW( 167 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 168 [In, MarshalAs(UnmanagedType.LPWStr)] 169 /*SQLCHAR* */string StatementText, 170 /*SQLINTEGER*/Int32 TextLength); 171 172 [DllImport(ExternDll.Odbc32)] 173 [ResourceExposure(ResourceScope.None)] SQLExecute( OdbcStatementHandle StatementHandle)174 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLExecute( 175 /*SQLHSTMT*/OdbcStatementHandle StatementHandle); 176 177 [DllImport(ExternDll.Odbc32)] 178 [ResourceExposure(ResourceScope.None)] SQLFetch( OdbcStatementHandle StatementHandle)179 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLFetch( 180 /*SQLHSTMT*/OdbcStatementHandle StatementHandle); 181 182 [DllImport(ExternDll.Odbc32)] 183 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] 184 [ResourceExposure(ResourceScope.None)] SQLFreeHandle( ODBC32.SQL_HANDLE HandleType, IntPtr StatementHandle)185 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLFreeHandle( 186 /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType, 187 /*SQLHSTMT*/IntPtr StatementHandle); 188 189 [DllImport(ExternDll.Odbc32)] 190 [ResourceExposure(ResourceScope.None)] SQLFreeStmt( OdbcStatementHandle StatementHandle, ODBC32.STMT Option)191 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLFreeStmt( 192 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 193 /*SQLUSMALLINT*/ODBC32.STMT Option); 194 195 [DllImport(ExternDll.Odbc32)] 196 [ResourceExposure(ResourceScope.None)] SQLGetConnectAttrW( OdbcConnectionHandle ConnectionHandle, ODBC32.SQL_ATTR Attribute, byte[] Value, Int32 BufferLength, out Int32 StringLength)197 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetConnectAttrW( 198 /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle, 199 /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, 200 /*SQLPOINTER*/byte[] Value, 201 /*SQLINTEGER*/Int32 BufferLength, 202 /*SQLINTEGER* */out Int32 StringLength); 203 204 [DllImport(ExternDll.Odbc32)] 205 [ResourceExposure(ResourceScope.None)] SQLGetData( OdbcStatementHandle StatementHandle, UInt16 ColumnNumber, ODBC32.SQL_C TargetType, CNativeBuffer TargetValue, IntPtr BufferLength, out IntPtr StrLen_or_Ind)206 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetData( 207 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 208 /*SQLUSMALLINT*/UInt16 ColumnNumber, 209 /*SQLSMALLINT*/ODBC32.SQL_C TargetType, 210 /*SQLPOINTER*/CNativeBuffer TargetValue, 211 /*SQLLEN*/IntPtr BufferLength, // sql.h differs from MSDN 212 /*SQLLEN* */out IntPtr StrLen_or_Ind); 213 214 [DllImport(ExternDll.Odbc32)] 215 [ResourceExposure(ResourceScope.None)] SQLGetDescFieldW( OdbcDescriptorHandle StatementHandle, Int16 RecNumber, ODBC32.SQL_DESC FieldIdentifier, CNativeBuffer ValuePointer, Int32 BufferLength, out Int32 StringLength)216 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetDescFieldW ( 217 /*SQLHSTMT*/OdbcDescriptorHandle StatementHandle, 218 /*SQLUSMALLINT*/Int16 RecNumber, 219 /*SQLUSMALLINT*/ODBC32.SQL_DESC FieldIdentifier, 220 /*SQLPOINTER*/CNativeBuffer ValuePointer, 221 /*SQLINTEGER*/Int32 BufferLength, 222 /*SQLINTEGER* */out Int32 StringLength); 223 224 [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)] 225 [ResourceExposure(ResourceScope.None)] SQLGetDiagRecW( ODBC32.SQL_HANDLE HandleType, OdbcHandle Handle, Int16 RecNumber, StringBuilder rchState, out Int32 NativeError, StringBuilder MessageText, Int16 BufferLength, out Int16 TextLength)226 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetDiagRecW( 227 /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType, 228 /*SQLHANDLE*/OdbcHandle Handle, 229 /*SQLSMALLINT*/Int16 RecNumber, 230 /*SQLCHAR* */ StringBuilder rchState, 231 /*SQLINTEGER* */out Int32 NativeError, 232 /*SQLCHAR* */StringBuilder MessageText, 233 /*SQLSMALLINT*/Int16 BufferLength, 234 /*SQLSMALLINT* */out Int16 TextLength); 235 236 [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)] 237 [ResourceExposure(ResourceScope.None)] SQLGetDiagFieldW( ODBC32.SQL_HANDLE HandleType, OdbcHandle Handle, Int16 RecNumber, Int16 DiagIdentifier, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder rchState, Int16 BufferLength, out Int16 StringLength)238 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetDiagFieldW( 239 /*SQLSMALLINT*/ ODBC32.SQL_HANDLE HandleType, 240 /*SQLHANDLE*/ OdbcHandle Handle, 241 /*SQLSMALLINT*/ Int16 RecNumber, 242 /*SQLSMALLINT*/ Int16 DiagIdentifier, 243 [MarshalAs(UnmanagedType.LPWStr)] 244 /*SQLPOINTER*/ StringBuilder rchState, 245 /*SQLSMALLINT*/ Int16 BufferLength, 246 /*SQLSMALLINT* */ out Int16 StringLength); 247 248 [DllImport(ExternDll.Odbc32)] 249 [ResourceExposure(ResourceScope.None)] SQLGetFunctions( OdbcConnectionHandle hdbc, ODBC32.SQL_API fFunction, out Int16 pfExists)250 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetFunctions( 251 /*SQLHBDC*/OdbcConnectionHandle hdbc, 252 /*SQLUSMALLINT*/ODBC32.SQL_API fFunction, 253 /*SQLUSMALLINT* */out Int16 pfExists); 254 255 [DllImport(ExternDll.Odbc32)] 256 [ResourceExposure(ResourceScope.None)] SQLGetInfoW( OdbcConnectionHandle hdbc, ODBC32.SQL_INFO fInfoType, byte[] rgbInfoValue, Int16 cbInfoValueMax, out Int16 pcbInfoValue)257 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetInfoW( 258 /*SQLHBDC*/OdbcConnectionHandle hdbc, 259 /*SQLUSMALLINT*/ODBC32.SQL_INFO fInfoType, 260 /*SQLPOINTER*/byte[] rgbInfoValue, 261 /*SQLSMALLINT*/Int16 cbInfoValueMax, 262 /*SQLSMALLINT* */out Int16 pcbInfoValue); 263 264 [DllImport(ExternDll.Odbc32)] 265 [ResourceExposure(ResourceScope.None)] SQLGetInfoW( OdbcConnectionHandle hdbc, ODBC32.SQL_INFO fInfoType, byte[] rgbInfoValue, Int16 cbInfoValueMax, IntPtr pcbInfoValue)266 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetInfoW( 267 /*SQLHBDC*/OdbcConnectionHandle hdbc, 268 /*SQLUSMALLINT*/ODBC32.SQL_INFO fInfoType, 269 /*SQLPOINTER*/byte[] rgbInfoValue, 270 /*SQLSMALLINT*/Int16 cbInfoValueMax, 271 /*SQLSMALLINT* */IntPtr pcbInfoValue); 272 273 [DllImport(ExternDll.Odbc32)] 274 [ResourceExposure(ResourceScope.None)] SQLGetStmtAttrW( OdbcStatementHandle StatementHandle, ODBC32.SQL_ATTR Attribute, out IntPtr Value, Int32 BufferLength, out Int32 StringLength)275 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetStmtAttrW( 276 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 277 /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, 278 /*SQLPOINTER*/out IntPtr Value, 279 /*SQLINTEGER*/Int32 BufferLength, 280 /*SQLINTEGER*/out Int32 StringLength); 281 282 [DllImport(ExternDll.Odbc32)] 283 [ResourceExposure(ResourceScope.None)] SQLGetTypeInfo( OdbcStatementHandle StatementHandle, Int16 fSqlType)284 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetTypeInfo( 285 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 286 /*SQLSMALLINT*/Int16 fSqlType); 287 288 [DllImport(ExternDll.Odbc32)] 289 [ResourceExposure(ResourceScope.None)] SQLMoreResults( OdbcStatementHandle StatementHandle)290 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLMoreResults( 291 /*SQLHSTMT*/OdbcStatementHandle StatementHandle); 292 293 [DllImport(ExternDll.Odbc32)] 294 [ResourceExposure(ResourceScope.None)] SQLNumResultCols( OdbcStatementHandle StatementHandle, out Int16 ColumnCount)295 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLNumResultCols( 296 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 297 /*SQLSMALLINT* */out Int16 ColumnCount); 298 299 [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)] 300 [ResourceExposure(ResourceScope.None)] SQLPrepareW( OdbcStatementHandle StatementHandle, [In, MarshalAs(UnmanagedType.LPWStr)] string StatementText, Int32 TextLength)301 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLPrepareW( 302 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 303 [In, MarshalAs(UnmanagedType.LPWStr)] 304 /*SQLCHAR* */string StatementText, 305 /*SQLINTEGER*/Int32 TextLength); 306 307 [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)] 308 [ResourceExposure(ResourceScope.None)] SQLPrimaryKeysW( OdbcStatementHandle StatementHandle, [In, MarshalAs(UnmanagedType.LPWStr)] string CatalogName, Int16 NameLen1, [In, MarshalAs(UnmanagedType.LPWStr)] string SchemaName, Int16 NameLen2, [In, MarshalAs(UnmanagedType.LPWStr)] string TableName, Int16 NameLen3)309 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLPrimaryKeysW ( 310 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 311 [In, MarshalAs(UnmanagedType.LPWStr)] 312 /*SQLCHAR* */string CatalogName, 313 /*SQLSMALLINT*/Int16 NameLen1, 314 [In, MarshalAs(UnmanagedType.LPWStr)] 315 /*SQLCHAR* */ string SchemaName, 316 /*SQLSMALLINT*/Int16 NameLen2, 317 [In, MarshalAs(UnmanagedType.LPWStr)] 318 /*SQLCHAR* */string TableName, 319 /*SQLSMALLINT*/Int16 NameLen3); 320 321 [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)] 322 [ResourceExposure(ResourceScope.None)] SQLProcedureColumnsW( OdbcStatementHandle StatementHandle, [In, MarshalAs(UnmanagedType.LPWStr)] string CatalogName, Int16 NameLen1, [In, MarshalAs(UnmanagedType.LPWStr)] string SchemaName, Int16 NameLen2, [In, MarshalAs(UnmanagedType.LPWStr)] string ProcName, Int16 NameLen3, [In, MarshalAs(UnmanagedType.LPWStr)] string ColumnName, Int16 NameLen4)323 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLProcedureColumnsW ( 324 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 325 [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string CatalogName, 326 /*SQLSMALLINT*/Int16 NameLen1, 327 [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string SchemaName, 328 /*SQLSMALLINT*/Int16 NameLen2, 329 [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string ProcName, 330 /*SQLSMALLINT*/Int16 NameLen3, 331 [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string ColumnName, 332 /*SQLSMALLINT*/Int16 NameLen4); 333 334 [DllImport(ExternDll.Odbc32)] 335 [ResourceExposure(ResourceScope.None)] SQLProceduresW( OdbcStatementHandle StatementHandle, [In, MarshalAs(UnmanagedType.LPWStr)] string CatalogName, Int16 NameLen1, [In, MarshalAs(UnmanagedType.LPWStr)] string SchemaName, Int16 NameLen2, [In, MarshalAs(UnmanagedType.LPWStr)] string ProcName, Int16 NameLen3)336 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLProceduresW ( 337 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 338 [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string CatalogName, 339 /*SQLSMALLINT*/Int16 NameLen1, 340 [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string SchemaName, 341 /*SQLSMALLINT*/Int16 NameLen2, 342 [In, MarshalAs(UnmanagedType.LPWStr)] /*SQLCHAR* */ string ProcName, 343 /*SQLSMALLINT*/Int16 NameLen3); 344 345 [DllImport(ExternDll.Odbc32)] 346 [ResourceExposure(ResourceScope.None)] SQLRowCount( OdbcStatementHandle StatementHandle, out IntPtr RowCount)347 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLRowCount( 348 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 349 /*SQLLEN* */out IntPtr RowCount); 350 351 [DllImport(ExternDll.Odbc32)] 352 [ResourceExposure(ResourceScope.None)] SQLSetConnectAttrW( OdbcConnectionHandle ConnectionHandle, ODBC32.SQL_ATTR Attribute, System.Transactions.IDtcTransaction Value, Int32 StringLength)353 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW( 354 /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle, 355 /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, 356 /*SQLPOINTER*/System.Transactions.IDtcTransaction Value, 357 /*SQLINTEGER*/Int32 StringLength); 358 359 [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)] 360 [ResourceExposure(ResourceScope.None)] SQLSetConnectAttrW( OdbcConnectionHandle ConnectionHandle, ODBC32.SQL_ATTR Attribute, string Value, Int32 StringLength)361 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW( 362 /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle, 363 /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, 364 /*SQLPOINTER*/string Value, 365 /*SQLINTEGER*/Int32 StringLength); 366 367 [DllImport(ExternDll.Odbc32)] 368 [ResourceExposure(ResourceScope.None)] SQLSetConnectAttrW( OdbcConnectionHandle ConnectionHandle, ODBC32.SQL_ATTR Attribute, IntPtr Value, Int32 StringLength)369 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW( 370 /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle, 371 /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, 372 /*SQLPOINTER*/IntPtr Value, 373 /*SQLINTEGER*/Int32 StringLength); 374 375 [DllImport(ExternDll.Odbc32)] 376 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] 377 [ResourceExposure(ResourceScope.None)] SQLSetConnectAttrW( IntPtr ConnectionHandle, ODBC32.SQL_ATTR Attribute, IntPtr Value, Int32 StringLength)378 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW( // used only for AutoCommitOn 379 /*SQLHBDC*/IntPtr ConnectionHandle, 380 /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, 381 /*SQLPOINTER*/IntPtr Value, 382 /*SQLINTEGER*/Int32 StringLength); 383 384 [DllImport(ExternDll.Odbc32)] 385 [ResourceExposure(ResourceScope.None)] SQLSetDescFieldW( OdbcDescriptorHandle StatementHandle, Int16 ColumnNumber, ODBC32.SQL_DESC FieldIdentifier, HandleRef CharacterAttribute, Int32 BufferLength)386 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetDescFieldW ( 387 /*SQLHSTMT*/OdbcDescriptorHandle StatementHandle, 388 /*SQLSMALLINT*/Int16 ColumnNumber, 389 /*SQLSMALLINT*/ODBC32.SQL_DESC FieldIdentifier, 390 /*SQLPOINTER*/HandleRef CharacterAttribute, 391 /*SQLINTEGER*/Int32 BufferLength); 392 393 [DllImport(ExternDll.Odbc32)] 394 [ResourceExposure(ResourceScope.None)] SQLSetDescFieldW( OdbcDescriptorHandle StatementHandle, Int16 ColumnNumber, ODBC32.SQL_DESC FieldIdentifier, IntPtr CharacterAttribute, Int32 BufferLength)395 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetDescFieldW ( 396 /*SQLHSTMT*/OdbcDescriptorHandle StatementHandle, 397 /*SQLSMALLINT*/Int16 ColumnNumber, 398 /*SQLSMALLINT*/ODBC32.SQL_DESC FieldIdentifier, 399 /*SQLPOINTER*/IntPtr CharacterAttribute, 400 /*SQLINTEGER*/Int32 BufferLength); 401 402 [DllImport(ExternDll.Odbc32)] 403 // user can set SQL_ATTR_CONNECTION_POOLING attribute with envHandle = null, this attribute is process-level attribute 404 [ResourceExposure(ResourceScope.Process)] SQLSetEnvAttr( OdbcEnvironmentHandle EnvironmentHandle, ODBC32.SQL_ATTR Attribute, IntPtr Value, ODBC32.SQL_IS StringLength)405 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetEnvAttr( 406 /*SQLHENV*/OdbcEnvironmentHandle EnvironmentHandle, 407 /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, 408 /*SQLPOINTER*/IntPtr Value, 409 /*SQLINTEGER*/ODBC32.SQL_IS StringLength); 410 411 [DllImport(ExternDll.Odbc32)] 412 [ResourceExposure(ResourceScope.None)] SQLSetStmtAttrW( OdbcStatementHandle StatementHandle, Int32 Attribute, IntPtr Value, Int32 StringLength)413 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetStmtAttrW( 414 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 415 /*SQLINTEGER*/Int32 Attribute, 416 /*SQLPOINTER*/IntPtr Value, 417 /*SQLINTEGER*/Int32 StringLength); 418 419 [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)] 420 [ResourceExposure(ResourceScope.None)] SQLSpecialColumnsW( OdbcStatementHandle StatementHandle, ODBC32.SQL_SPECIALCOLS IdentifierType, [In, MarshalAs(UnmanagedType.LPWStr)] string CatalogName, Int16 NameLen1, [In, MarshalAs(UnmanagedType.LPWStr)] string SchemaName, Int16 NameLen2, [In, MarshalAs(UnmanagedType.LPWStr)] string TableName, Int16 NameLen3, ODBC32.SQL_SCOPE Scope, ODBC32.SQL_NULLABILITY Nullable)421 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSpecialColumnsW ( 422 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 423 /*SQLUSMALLINT*/ODBC32.SQL_SPECIALCOLS IdentifierType, 424 [In, MarshalAs(UnmanagedType.LPWStr)] 425 /*SQLCHAR* */string CatalogName, 426 /*SQLSMALLINT*/Int16 NameLen1, 427 [In, MarshalAs(UnmanagedType.LPWStr)] 428 /*SQLCHAR* */string SchemaName, 429 /*SQLSMALLINT*/Int16 NameLen2, 430 [In, MarshalAs(UnmanagedType.LPWStr)] 431 /*SQLCHAR* */string TableName, 432 /*SQLSMALLINT*/Int16 NameLen3, 433 /*SQLUSMALLINT*/ODBC32.SQL_SCOPE Scope, 434 /*SQLUSMALLINT*/ ODBC32.SQL_NULLABILITY Nullable); 435 436 [DllImport(ExternDll.Odbc32, CharSet=CharSet.Unicode)] 437 [ResourceExposure(ResourceScope.None)] SQLStatisticsW( OdbcStatementHandle StatementHandle, [In, MarshalAs(UnmanagedType.LPWStr)] string CatalogName, Int16 NameLen1, [In, MarshalAs(UnmanagedType.LPWStr)] string SchemaName, Int16 NameLen2, [In, MarshalAs(UnmanagedType.LPWStr)] string TableName, Int16 NameLen3, Int16 Unique, Int16 Reserved)438 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLStatisticsW ( 439 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 440 [In, MarshalAs(UnmanagedType.LPWStr)] 441 /*SQLCHAR* */string CatalogName, 442 /*SQLSMALLINT*/Int16 NameLen1, 443 [In, MarshalAs(UnmanagedType.LPWStr)] 444 /*SQLCHAR* */string SchemaName, 445 /*SQLSMALLINT*/Int16 NameLen2, 446 [In, MarshalAs(UnmanagedType.LPWStr)] 447 /*SQLCHAR* */string TableName, 448 /*SQLSMALLINT*/Int16 NameLen3, 449 /*SQLUSMALLINT*/Int16 Unique, 450 /*SQLUSMALLINT*/Int16 Reserved); 451 452 [DllImport(ExternDll.Odbc32)] 453 [ResourceExposure(ResourceScope.None)] SQLTablesW( OdbcStatementHandle StatementHandle, [In, MarshalAs(UnmanagedType.LPWStr)] string CatalogName, Int16 NameLen1, [In, MarshalAs(UnmanagedType.LPWStr)] string SchemaName, Int16 NameLen2, [In, MarshalAs(UnmanagedType.LPWStr)] string TableName, Int16 NameLen3, [In, MarshalAs(UnmanagedType.LPWStr)] string TableType, Int16 NameLen4)454 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLTablesW ( 455 /*SQLHSTMT*/OdbcStatementHandle StatementHandle, 456 [In, MarshalAs(UnmanagedType.LPWStr)] 457 /*SQLCHAR* */string CatalogName, 458 /*SQLSMALLINT*/Int16 NameLen1, 459 [In, MarshalAs(UnmanagedType.LPWStr)] 460 /*SQLCHAR* */string SchemaName, 461 /*SQLSMALLINT*/Int16 NameLen2, 462 [In, MarshalAs(UnmanagedType.LPWStr)] 463 /*SQLCHAR* */string TableName, 464 /*SQLSMALLINT*/Int16 NameLen3, 465 [In, MarshalAs(UnmanagedType.LPWStr)] 466 /*SQLCHAR* */string TableType, 467 /*SQLSMALLINT*/Int16 NameLen4); 468 #endif 469 470 #if !NO_OLEDB 471 // 472 // Oleaut32 473 // 474 475 [DllImport(ExternDll.Oleaut32, CharSet=CharSet.Unicode, PreserveSig=true)] 476 [ResourceExposure(ResourceScope.None)] GetErrorInfo( [In] Int32 dwReserved, [Out, MarshalAs(UnmanagedType.Interface)] out IErrorInfo ppIErrorInfo)477 static internal extern System.Data.OleDb.OleDbHResult GetErrorInfo( 478 [In] Int32 dwReserved, 479 [Out, MarshalAs(UnmanagedType.Interface)] out IErrorInfo ppIErrorInfo); 480 481 [Guid("00000567-0000-0010-8000-00AA006D2EA4"), InterfaceType(ComInterfaceType.InterfaceIsDual), ComImport, SuppressUnmanagedCodeSecurity] 482 internal interface ADORecordConstruction { 483 get_Row()484 [return:MarshalAs(UnmanagedType.Interface)] object get_Row (); 485 486 //void put_Row( 487 // [In, MarshalAs(UnmanagedType.Interface)] object pRow); 488 489 //void put_ParentRow( 490 // [In, MarshalAs(UnmanagedType.Interface)]object pRow); 491 } 492 493 [Guid("00000283-0000-0010-8000-00AA006D2EA4"), InterfaceType(ComInterfaceType.InterfaceIsDual), ComImport, SuppressUnmanagedCodeSecurity] 494 internal interface ADORecordsetConstruction { 495 get_Rowset()496 [return:MarshalAs(UnmanagedType.Interface)] object get_Rowset(); 497 put_Rowset( )498 [ Obsolete("not used", true)] void put_Rowset (/*deleted parameters signature*/); 499 get_Chapter()500 /*[return:MarshalAs(UnmanagedType.SysInt)]*/ IntPtr get_Chapter(); 501 502 //[[PreserveSig] 503 //iint put_Chapter ( 504 // [In] 505 // IntPtr pcRefCount); 506 507 //[[PreserveSig] 508 //iint get_RowPosition ( 509 // [Out, MarshalAs(UnmanagedType.Interface)] 510 // out object ppRowPos); 511 512 //[[PreserveSig] 513 //iint put_RowPosition ( 514 // [In, MarshalAs(UnmanagedType.Interface)] 515 // object pRowPos); 516 } 517 518 [Guid("0000050E-0000-0010-8000-00AA006D2EA4"), InterfaceType(ComInterfaceType.InterfaceIsDual), ComImport, SuppressUnmanagedCodeSecurity] 519 internal interface Recordset15 { get_Properties( )520 [ Obsolete("not used", true)] void get_Properties(/*deleted parameters signature*/); get_AbsolutePosition( )521 [ Obsolete("not used", true)] void get_AbsolutePosition(/*deleted parameters signature*/); put_AbsolutePosition( )522 [ Obsolete("not used", true)] void put_AbsolutePosition(/*deleted parameters signature*/); putref_ActiveConnection( )523 [ Obsolete("not used", true)] void putref_ActiveConnection(/*deleted parameters signature*/); put_ActiveConnection( )524 [ Obsolete("not used", true)] void put_ActiveConnection(/*deleted parameters signature*/); 525 get_ActiveConnection()526 /*[return:MarshalAs(UnmanagedType.Variant)]*/object get_ActiveConnection(); 527 get_BOF( )528 [ Obsolete("not used", true)] void get_BOF(/*deleted parameters signature*/); get_Bookmark( )529 [ Obsolete("not used", true)] void get_Bookmark(/*deleted parameters signature*/); put_Bookmark( )530 [ Obsolete("not used", true)] void put_Bookmark(/*deleted parameters signature*/); get_CacheSize( )531 [ Obsolete("not used", true)] void get_CacheSize(/*deleted parameters signature*/); put_CacheSize( )532 [ Obsolete("not used", true)] void put_CacheSize(/*deleted parameters signature*/); get_CursorType( )533 [ Obsolete("not used", true)] void get_CursorType(/*deleted parameters signature*/); put_CursorType( )534 [ Obsolete("not used", true)] void put_CursorType(/*deleted parameters signature*/); get_EOF( )535 [ Obsolete("not used", true)] void get_EOF(/*deleted parameters signature*/); get_Fields( )536 [ Obsolete("not used", true)] void get_Fields(/*deleted parameters signature*/); get_LockType( )537 [ Obsolete("not used", true)] void get_LockType(/*deleted parameters signature*/); put_LockType( )538 [ Obsolete("not used", true)] void put_LockType(/*deleted parameters signature*/); get_MaxRecords( )539 [ Obsolete("not used", true)] void get_MaxRecords(/*deleted parameters signature*/); put_MaxRecords( )540 [ Obsolete("not used", true)] void put_MaxRecords(/*deleted parameters signature*/); get_RecordCount( )541 [ Obsolete("not used", true)] void get_RecordCount(/*deleted parameters signature*/); putref_Source( )542 [ Obsolete("not used", true)] void putref_Source(/*deleted parameters signature*/); put_Source( )543 [ Obsolete("not used", true)] void put_Source(/*deleted parameters signature*/); get_Source( )544 [ Obsolete("not used", true)] void get_Source(/*deleted parameters signature*/); AddNew( )545 [ Obsolete("not used", true)] void AddNew(/*deleted parameters signature*/); CancelUpdate( )546 [ Obsolete("not used", true)] void CancelUpdate(/*deleted parameters signature*/); 547 Close()548 [PreserveSig] System.Data.OleDb.OleDbHResult Close(); 549 Delete( )550 [ Obsolete("not used", true)] void Delete(/*deleted parameters signature*/); GetRows( )551 [ Obsolete("not used", true)] void GetRows(/*deleted parameters signature*/); Move( )552 [ Obsolete("not used", true)] void Move(/*deleted parameters signature*/); MoveNext()553 [ Obsolete("not used", true)] void MoveNext(); MovePrevious()554 [ Obsolete("not used", true)] void MovePrevious(); MoveFirst()555 [ Obsolete("not used", true)] void MoveFirst(); MoveLast()556 [ Obsolete("not used", true)] void MoveLast(); Open( )557 [ Obsolete("not used", true)] void Open(/*deleted parameters signature*/); Requery( )558 [ Obsolete("not used", true)] void Requery(/*deleted parameters signature*/); _xResync( )559 [ Obsolete("not used", true)] void _xResync(/*deleted parameters signature*/); Update( )560 [ Obsolete("not used", true)] void Update(/*deleted parameters signature*/); get_AbsolutePage( )561 [ Obsolete("not used", true)] void get_AbsolutePage(/*deleted parameters signature*/); put_AbsolutePage( )562 [ Obsolete("not used", true)] void put_AbsolutePage(/*deleted parameters signature*/); get_EditMode( )563 [ Obsolete("not used", true)] void get_EditMode(/*deleted parameters signature*/); get_Filter( )564 [ Obsolete("not used", true)] void get_Filter(/*deleted parameters signature*/); put_Filter( )565 [ Obsolete("not used", true)] void put_Filter(/*deleted parameters signature*/); get_PageCount( )566 [ Obsolete("not used", true)] void get_PageCount(/*deleted parameters signature*/); get_PageSize( )567 [ Obsolete("not used", true)] void get_PageSize(/*deleted parameters signature*/); put_PageSize( )568 [ Obsolete("not used", true)] void put_PageSize(/*deleted parameters signature*/); get_Sort( )569 [ Obsolete("not used", true)] void get_Sort(/*deleted parameters signature*/); put_Sort( )570 [ Obsolete("not used", true)] void put_Sort(/*deleted parameters signature*/); get_Status( )571 [ Obsolete("not used", true)] void get_Status(/*deleted parameters signature*/); get_State( )572 [ Obsolete("not used", true)] void get_State(/*deleted parameters signature*/); _xClone( )573 [ Obsolete("not used", true)] void _xClone(/*deleted parameters signature*/); UpdateBatch( )574 [ Obsolete("not used", true)] void UpdateBatch(/*deleted parameters signature*/); CancelBatch( )575 [ Obsolete("not used", true)] void CancelBatch(/*deleted parameters signature*/); get_CursorLocation( )576 [ Obsolete("not used", true)] void get_CursorLocation(/*deleted parameters signature*/); put_CursorLocation( )577 [ Obsolete("not used", true)] void put_CursorLocation(/*deleted parameters signature*/); 578 NextRecordset( [Out]out object RecordsAffected, [Out, MarshalAs(UnmanagedType.Interface)] out object ppiRs)579 [PreserveSig] System.Data.OleDb.OleDbHResult NextRecordset( 580 [Out]out object RecordsAffected, 581 [Out, MarshalAs(UnmanagedType.Interface)] out object ppiRs); 582 583 //[ Obsolete("not used", true)] void Supports(/*deleted parameters signature*/); 584 //[ Obsolete("not used", true)] void get_Collect(/*deleted parameters signature*/); 585 //[ Obsolete("not used", true)] void put_Collect(/*deleted parameters signature*/); 586 //[ Obsolete("not used", true)] void get_MarshalOptions(/*deleted parameters signature*/); 587 //[ Obsolete("not used", true)] void put_MarshalOptions(/*deleted parameters signature*/); 588 //[ Obsolete("not used", true)] void Find(/*deleted parameters signature*/); 589 } 590 591 [Guid("00000562-0000-0010-8000-00AA006D2EA4"), InterfaceType(ComInterfaceType.InterfaceIsDual), ComImport, SuppressUnmanagedCodeSecurity] 592 internal interface _ADORecord { get_Properties( )593 [ Obsolete("not used", true)] void get_Properties(/*deleted parameters signature*/); 594 get_ActiveConnection()595 /*[return:MarshalAs(UnmanagedType.Variant)]*/object get_ActiveConnection(); 596 put_ActiveConnection( )597 [ Obsolete("not used", true)] void put_ActiveConnection(/*deleted parameters signature*/); putref_ActiveConnection( )598 [ Obsolete("not used", true)] void putref_ActiveConnection(/*deleted parameters signature*/); get_State( )599 [ Obsolete("not used", true)] void get_State(/*deleted parameters signature*/); get_Source( )600 [ Obsolete("not used", true)] void get_Source(/*deleted parameters signature*/); put_Source( )601 [ Obsolete("not used", true)] void put_Source(/*deleted parameters signature*/); putref_Source( )602 [ Obsolete("not used", true)] void putref_Source(/*deleted parameters signature*/); get_Mode( )603 [ Obsolete("not used", true)] void get_Mode(/*deleted parameters signature*/); put_Mode( )604 [ Obsolete("not used", true)] void put_Mode(/*deleted parameters signature*/); get_ParentURL( )605 [ Obsolete("not used", true)] void get_ParentURL(/*deleted parameters signature*/); MoveRecord( )606 [ Obsolete("not used", true)] void MoveRecord(/*deleted parameters signature*/); CopyRecord( )607 [ Obsolete("not used", true)] void CopyRecord(/*deleted parameters signature*/); DeleteRecord( )608 [ Obsolete("not used", true)] void DeleteRecord(/*deleted parameters signature*/); Open( )609 [ Obsolete("not used", true)] void Open(/*deleted parameters signature*/); 610 Close()611 [PreserveSig] System.Data.OleDb.OleDbHResult Close(); 612 613 //[ Obsolete("not used", true)] void get_Fields(/*deleted parameters signature*/); 614 //[ Obsolete("not used", true)] void get_RecordType(/*deleted parameters signature*/); 615 //[ Obsolete("not used", true)] void GetChildren(/*deleted parameters signature*/); 616 //[ Obsolete("not used", true)] void Cancel(); 617 } 618 619 /* 620 typedef ULONGLONG DBLENGTH; 621 622 // Offset within a rowset 623 typedef LONGLONG DBROWOFFSET; 624 625 // Number of rows 626 typedef LONGLONG DBROWCOUNT; 627 628 typedef ULONGLONG DBCOUNTITEM; 629 630 // Ordinal (column number, etc.) 631 typedef ULONGLONG DBORDINAL; 632 633 typedef LONGLONG DB_LORDINAL; 634 635 // Bookmarks 636 typedef ULONGLONG DBBKMARK; 637 // Offset in the buffer 638 639 typedef ULONGLONG DBBYTEOFFSET; 640 // Reference count of each row/accessor handle 641 642 typedef ULONG DBREFCOUNT; 643 644 // Parameters 645 typedef ULONGLONG DB_UPARAMS; 646 647 typedef LONGLONG DB_LPARAMS; 648 649 // hash values corresponding to the elements (bookmarks) 650 typedef DWORDLONG DBHASHVALUE; 651 652 // For reserve 653 typedef DWORDLONG DB_DWRESERVE; 654 655 typedef LONGLONG DB_LRESERVE; 656 657 typedef ULONGLONG DB_URESERVE; 658 */ 659 660 661 662 [ComImport, Guid("0C733A8C-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), SuppressUnmanagedCodeSecurity] 663 internal interface IAccessor { 664 AddRefAccessor( )665 [ Obsolete("not used", true)] void AddRefAccessor(/*deleted parameters signature*/); 666 667 /*[local] 668 HRESULT CreateAccessor( 669 [in] DBACCESSORFLAGS dwAccessorFlags, 670 [in] DBCOUNTITEM cBindings, 671 [in, size_is(cBindings)] const DBBINDING rgBindings[], 672 [in] DBLENGTH cbRowSize, 673 [out] HACCESSOR * phAccessor, 674 [out, size_is(cBindings)] DBBINDSTATUS rgStatus[] 675 );*/ CreateAccessor( [In] int dwAccessorFlags, [In] IntPtr cBindings, [In] SafeHandle rgBindings, [In] IntPtr cbRowSize, [Out] out IntPtr phAccessor, [In, Out, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.I4)] int[] rgStatus)676 [PreserveSig] System.Data.OleDb.OleDbHResult CreateAccessor( 677 [In] int dwAccessorFlags, 678 [In] IntPtr cBindings, 679 [In] /*tagDBBINDING[]*/SafeHandle rgBindings, 680 [In] IntPtr cbRowSize, 681 [Out] out IntPtr phAccessor, 682 [In, Out, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.I4)] int[] rgStatus); 683 GetBindings( )684 [ Obsolete("not used", true)] void GetBindings(/*deleted parameters signature*/); 685 686 /*[local] 687 HRESULT ReleaseAccessor( 688 [in] HACCESSOR hAccessor, 689 [in, out, unique] DBREFCOUNT * pcRefCount 690 );*/ ReleaseAccessor( [In] IntPtr hAccessor, [Out] out int pcRefCount)691 [PreserveSig] System.Data.OleDb.OleDbHResult ReleaseAccessor( 692 [In] IntPtr hAccessor, 693 [Out] out int pcRefCount); 694 } 695 696 [Guid("0C733A93-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 697 internal interface IChapteredRowset { 698 AddRefChapter( )699 [ Obsolete("not used", true)] void AddRefChapter(/*deleted parameters signature*/); 700 701 /*[local] 702 HRESULT ReleaseChapter( 703 [in] HCHAPTER hChapter, 704 [out] DBREFCOUNT * pcRefCount 705 );*/ ReleaseChapter( [In] IntPtr hChapter, [Out] out int pcRefCount)706 [PreserveSig, ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] System.Data.OleDb.OleDbHResult ReleaseChapter( 707 [In] IntPtr hChapter, 708 [Out] out int pcRefCount); 709 } 710 711 [Guid("0C733A11-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 712 internal interface IColumnsInfo { 713 714 /*[local] 715 HRESULT GetColumnInfo( 716 [in, out] DBORDINAL * pcColumns, 717 [out, size_is(,(ULONG)*pcColumns)] DBCOLUMNINFO ** prgInfo, 718 [out] OLECHAR ** ppStringsBuffer 719 );*/ GetColumnInfo( [Out] out IntPtr pcColumns, [Out] out IntPtr prgInfo, [Out] out IntPtr ppStringsBuffer)720 [PreserveSig] System.Data.OleDb.OleDbHResult GetColumnInfo( 721 [Out] out IntPtr pcColumns, 722 [Out] out IntPtr prgInfo, 723 [Out] out IntPtr ppStringsBuffer); 724 725 //[PreserveSig] 726 //int MapColumnIDs(/* deleted parameters*/); 727 } 728 729 [Guid("0C733A10-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 730 internal interface IColumnsRowset { 731 732 /*[local] 733 HRESULT GetAvailableColumns( 734 [in, out] DBORDINAL * pcOptColumns, 735 [out, size_is(,(ULONG)*pcOptColumns)] DBID ** prgOptColumns 736 );*/ GetAvailableColumns( [Out] out IntPtr pcOptColumns, [Out] out IntPtr prgOptColumns)737 [PreserveSig] System.Data.OleDb.OleDbHResult GetAvailableColumns( 738 [Out] out IntPtr pcOptColumns, 739 [Out] out IntPtr prgOptColumns); 740 741 /*[local] 742 HRESULT GetColumnsRowset( 743 [in] IUnknown * pUnkOuter, 744 [in] DBORDINAL cOptColumns, 745 [in, size_is((ULONG)cOptColumns)] const DBID rgOptColumns[], 746 [in] REFIID riid, 747 [in] ULONG cPropertySets, 748 [in, out, size_is((ULONG)cPropertySets)] DBPROPSET rgPropertySets[], 749 [out, iid_is(riid)] IUnknown ** ppColRowset 750 );*/ GetColumnsRowset( [In] IntPtr pUnkOuter, [In] IntPtr cOptColumns, [In] SafeHandle rgOptColumns, [In] ref Guid riid, [In] int cPropertySets, [In] IntPtr rgPropertySets, [Out, MarshalAs(UnmanagedType.Interface)] out IRowset ppColRowset)751 [PreserveSig] System.Data.OleDb.OleDbHResult GetColumnsRowset( 752 [In] IntPtr pUnkOuter, 753 [In] IntPtr cOptColumns, 754 [In] SafeHandle rgOptColumns, 755 [In] ref Guid riid, 756 [In] int cPropertySets, 757 [In] IntPtr rgPropertySets, 758 [Out, MarshalAs(UnmanagedType.Interface)] out IRowset ppColRowset); 759 } 760 761 762 [Guid("0C733A26-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 763 internal interface ICommandPrepare { 764 765 /*[local] 766 HRESULT Prepare( 767 [in] ULONG cExpectedRuns 768 );*/ Prepare( [In] int cExpectedRuns)769 [PreserveSig] System.Data.OleDb.OleDbHResult Prepare( 770 [In] int cExpectedRuns); 771 772 //[PreserveSig] 773 //int Unprepare(); 774 } 775 776 [Guid("0C733A79-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 777 internal interface ICommandProperties { 778 779 /*[local] 780 HRESULT GetProperties( 781 [in] const ULONG cPropertyIDSets, 782 [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[], 783 [in, out] ULONG * pcPropertySets, 784 [out, size_is(,*pcPropertySets)] DBPROPSET ** prgPropertySets 785 );*/ GetProperties( [In] int cPropertyIDSets, [In] SafeHandle rgPropertyIDSets, [Out] out int pcPropertySets, [Out] out IntPtr prgPropertySets)786 [PreserveSig] System.Data.OleDb.OleDbHResult GetProperties( 787 [In] int cPropertyIDSets, 788 [In] SafeHandle rgPropertyIDSets, 789 [Out] out int pcPropertySets, 790 [Out] out IntPtr prgPropertySets); 791 792 /*[local] 793 HRESULT SetProperties( 794 [in] ULONG cPropertySets, 795 [in, out, unique, size_is(cPropertySets)] DBPROPSET rgPropertySets[] 796 );*/ SetProperties( [In] int cPropertySets, [In] SafeHandle rgPropertySets)797 [PreserveSig] System.Data.OleDb.OleDbHResult SetProperties( 798 [In] int cPropertySets, 799 [In] SafeHandle rgPropertySets); 800 } 801 802 [Guid("0C733A27-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 803 internal interface ICommandText { 804 805 /*[local] 806 HRESULT Cancel( 807 );*/ Cancel()808 [PreserveSig] System.Data.OleDb.OleDbHResult Cancel(); 809 810 /*[local] 811 HRESULT Execute( 812 [in] IUnknown * pUnkOuter, 813 [in] REFIID riid, 814 [in, out] DBPARAMS * pParams, 815 [out] DBROWCOUNT * pcRowsAffected, 816 [out, iid_is(riid)] IUnknown ** ppRowset 817 );*/ Execute( [In] IntPtr pUnkOuter, [In] ref Guid riid, [In] System.Data.OleDb.tagDBPARAMS pDBParams, [Out] out IntPtr pcRowsAffected, [Out, MarshalAs(UnmanagedType.Interface)] out object ppRowset)818 [PreserveSig] System.Data.OleDb.OleDbHResult Execute( 819 [In] IntPtr pUnkOuter, 820 [In] ref Guid riid, 821 [In] System.Data.OleDb.tagDBPARAMS pDBParams, 822 [Out] out IntPtr pcRowsAffected, 823 [Out, MarshalAs(UnmanagedType.Interface)] out object ppRowset); 824 GetDBSession( )825 [ Obsolete("not used", true)] void GetDBSession(/*deleted parameter signature*/); 826 GetCommandText( )827 [ Obsolete("not used", true)] void GetCommandText(/*deleted parameter signature*/); 828 829 /*[local] 830 HRESULT SetCommandText( 831 [in] REFGUID rguidDialect, 832 [in, unique] LPCOLESTR pwszCommand 833 );*/ SetCommandText( [In] ref Guid rguidDialect, [In, MarshalAs(UnmanagedType.LPWStr)] string pwszCommand)834 [PreserveSig] System.Data.OleDb.OleDbHResult SetCommandText( 835 [In] ref Guid rguidDialect, 836 [In, MarshalAs(UnmanagedType.LPWStr)] string pwszCommand); 837 } 838 839 [Guid("0C733A64-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 840 internal interface ICommandWithParameters { 841 GetParameterInfo( )842 [ Obsolete("not used", true)] void GetParameterInfo(/*deleted parameters signature*/); 843 MapParameterNames( )844 [ Obsolete("not used", true)] void MapParameterNames(/*deleted parameter signature*/); 845 846 /*[local] 847 HRESULT SetParameterInfo( 848 [in] DB_UPARAMS cParams, 849 [in, unique, size_is((ULONG)cParams)] const DB_UPARAMS rgParamOrdinals[], 850 [in, unique, size_is((ULONG)cParams)] const DBPARAMBINDINFO rgParamBindInfo[] 851 );*/ SetParameterInfo( [In] IntPtr cParams, [In, MarshalAs(UnmanagedType.LPArray)] IntPtr[] rgParamOrdinals, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.Struct)] System.Data.OleDb.tagDBPARAMBINDINFO[] rgParamBindInfo)852 [PreserveSig] System.Data.OleDb.OleDbHResult SetParameterInfo( 853 [In] IntPtr cParams, 854 [In, MarshalAs(UnmanagedType.LPArray)] IntPtr[] rgParamOrdinals, 855 [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.Struct)] System.Data.OleDb.tagDBPARAMBINDINFO[] rgParamBindInfo); 856 } 857 858 [Guid("2206CCB1-19C1-11D1-89E0-00C04FD7A829"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 859 internal interface IDataInitialize { 860 861 } 862 863 [Guid("0C733A89-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 864 internal interface IDBInfo { 865 866 /*[local] 867 HRESULT GetKeywords( 868 [out] LPOLESTR * ppwszKeywords 869 );*/ GetKeywords( [Out, MarshalAs(UnmanagedType.LPWStr)] out string ppwszKeywords)870 [PreserveSig] System.Data.OleDb.OleDbHResult GetKeywords( 871 [Out, MarshalAs(UnmanagedType.LPWStr)] out string ppwszKeywords); 872 873 /*[local] 874 HRESULT GetLiteralInfo( 875 [in] ULONG cLiterals, 876 [in, size_is(cLiterals)] const DBLITERAL rgLiterals[], 877 [in, out] ULONG * pcLiteralInfo, 878 [out, size_is(,*pcLiteralInfo)] DBLITERALINFO ** prgLiteralInfo, 879 [out] OLECHAR ** ppCharBuffer 880 );*/ GetLiteralInfo( [In] int cLiterals, [In, MarshalAs(UnmanagedType.LPArray)] int[] rgLiterals, [Out] out int pcLiteralInfo, [Out] out IntPtr prgLiteralInfo, [Out] out IntPtr ppCharBuffer)881 [PreserveSig] System.Data.OleDb.OleDbHResult GetLiteralInfo( 882 [In] int cLiterals, 883 [In, MarshalAs(UnmanagedType.LPArray)] int[] rgLiterals, 884 [Out] out int pcLiteralInfo, 885 [Out] out IntPtr prgLiteralInfo, 886 [Out] out IntPtr ppCharBuffer); 887 } 888 889 [Guid("0C733A8A-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 890 internal interface IDBProperties { 891 892 /*[local] 893 HRESULT GetProperties( 894 [in] const ULONG cPropertyIDSets, 895 [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[], 896 [in, out] ULONG * pcPropertySets, 897 [out, size_is(,*pcPropertySets)] DBPROPSET ** prgPropertySets 898 );*/ GetProperties( [In] int cPropertyIDSets, [In] SafeHandle rgPropertyIDSets, [Out] out int pcPropertySets, [Out] out IntPtr prgPropertySets)899 [PreserveSig] System.Data.OleDb.OleDbHResult GetProperties( 900 [In] int cPropertyIDSets, 901 [In] SafeHandle rgPropertyIDSets, 902 [Out] out int pcPropertySets, 903 [Out] out IntPtr prgPropertySets); 904 GetPropertyInfo( [In] int cPropertyIDSets, [In] SafeHandle rgPropertyIDSets, [Out] out int pcPropertySets, [Out] out IntPtr prgPropertyInfoSets, [Out] out IntPtr ppDescBuffer)905 [PreserveSig] System.Data.OleDb.OleDbHResult GetPropertyInfo( 906 [In] int cPropertyIDSets, 907 [In] SafeHandle rgPropertyIDSets, 908 [Out] out int pcPropertySets, 909 [Out] out IntPtr prgPropertyInfoSets, 910 [Out] out IntPtr ppDescBuffer); 911 SetProperties( [In] int cPropertySets, [In] SafeHandle rgPropertySets)912 [PreserveSig] System.Data.OleDb.OleDbHResult SetProperties( 913 [In] int cPropertySets, 914 [In] SafeHandle rgPropertySets); 915 } 916 917 [Guid("0C733A7B-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 918 internal interface IDBSchemaRowset { 919 920 /*[local] 921 HRESULT GetRowset( 922 [in] IUnknown * pUnkOuter, 923 [in] REFGUID rguidSchema, 924 [in] ULONG cRestrictions, 925 [in, size_is(cRestrictions)] const VARIANT rgRestrictions[], 926 [in] REFIID riid, 927 [in] ULONG cPropertySets, 928 [in, out, unique, size_is(cPropertySets)] DBPROPSET rgPropertySets[], 929 [out, iid_is(riid)] IUnknown ** ppRowset 930 );*/ GetRowset( [In] IntPtr pUnkOuter, [In] ref Guid rguidSchema, [In] int cRestrictions, [In, MarshalAs(UnmanagedType.LPArray)] object[] rgRestrictions, [In] ref Guid riid, [In] int cPropertySets, [In] IntPtr rgPropertySets, [Out, MarshalAs(UnmanagedType.Interface)] out IRowset ppRowset)931 [PreserveSig] System.Data.OleDb.OleDbHResult GetRowset( 932 [In] IntPtr pUnkOuter, 933 [In] ref Guid rguidSchema, 934 [In] int cRestrictions, 935 [In, MarshalAs(UnmanagedType.LPArray)] object[] rgRestrictions, 936 [In] ref Guid riid, 937 [In] int cPropertySets, 938 [In] IntPtr rgPropertySets, 939 [Out, MarshalAs(UnmanagedType.Interface)] out IRowset ppRowset); 940 941 /*[local] 942 HRESULT GetSchemas( 943 [in, out] ULONG * pcSchemas, 944 [out, size_is(,*pcSchemas)] GUID ** prgSchemas, 945 [out, size_is(,*pcSchemas)] ULONG ** prgRestrictionSupport 946 );*/ GetSchemas( [Out] out int pcSchemas, [Out] out IntPtr rguidSchema, [Out] out IntPtr prgRestrictionSupport)947 [PreserveSig] System.Data.OleDb.OleDbHResult GetSchemas( 948 [Out] out int pcSchemas, 949 [Out] out IntPtr rguidSchema, 950 [Out] out IntPtr prgRestrictionSupport); 951 } 952 953 [Guid("1CF2B120-547D-101B-8E65-08002B2BD119"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 954 internal interface IErrorInfo { 955 GetGUID( )956 [ Obsolete("not used", true)] void GetGUID(/*deleted parameter signature*/); 957 GetSource( [Out, MarshalAs(UnmanagedType.BStr)] out string pBstrSource)958 [PreserveSig] System.Data.OleDb.OleDbHResult GetSource( 959 [Out, MarshalAs(UnmanagedType.BStr)] out string pBstrSource); 960 GetDescription( [Out, MarshalAs(UnmanagedType.BStr)] out string pBstrDescription)961 [PreserveSig] System.Data.OleDb.OleDbHResult GetDescription( 962 [Out, MarshalAs(UnmanagedType.BStr)] out string pBstrDescription); 963 964 //[ Obsolete("not used", true)] void GetHelpFile(/*deleted parameter signature*/); 965 966 //[ Obsolete("not used", true)] void GetHelpContext(/*deleted parameter signature*/); 967 } 968 #if false 969 MIDL_INTERFACE("1CF2B120-547D-101B-8E65-08002B2BD119") 970 IErrorInfo : public IUnknown GetGUID( GUID *pGUID)971 virtual HRESULT STDMETHODCALLTYPE GetGUID( 972 /* [out] */ GUID *pGUID) = 0; GetSource( BSTR *pBstrSource)973 virtual HRESULT STDMETHODCALLTYPE GetSource( 974 /* [out] */ BSTR *pBstrSource) = 0; GetDescription( BSTR *pBstrDescription)975 virtual HRESULT STDMETHODCALLTYPE GetDescription( 976 /* [out] */ BSTR *pBstrDescription) = 0; GetHelpFile( BSTR *pBstrHelpFile)977 virtual HRESULT STDMETHODCALLTYPE GetHelpFile( 978 /* [out] */ BSTR *pBstrHelpFile) = 0; GetHelpContext( DWORD *pdwHelpContext)979 virtual HRESULT STDMETHODCALLTYPE GetHelpContext( 980 /* [out] */ DWORD *pdwHelpContext) = 0; 981 #endif 982 983 [Guid("0C733A67-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 984 internal interface IErrorRecords { 985 AddErrorRecord( )986 [ Obsolete("not used", true)] void AddErrorRecord(/*deleted parameter signature*/); 987 GetBasicErrorInfo( )988 [ Obsolete("not used", true)] void GetBasicErrorInfo(/*deleted parameter signature*/); 989 GetCustomErrorObject( [In] Int32 ulRecordNum, [In] ref Guid riid, [Out, MarshalAs(UnmanagedType.Interface)] out ISQLErrorInfo ppObject)990 [PreserveSig] System.Data.OleDb.OleDbHResult GetCustomErrorObject( // may return E_NOINTERFACE when asking for IID_ISQLErrorInfo 991 [In] Int32 ulRecordNum, 992 [In] ref Guid riid, 993 [Out, MarshalAs(UnmanagedType.Interface)] out ISQLErrorInfo ppObject); 994 GetErrorInfo( [In] Int32 ulRecordNum, [In] Int32 lcid)995 [return:MarshalAs(UnmanagedType.Interface)] IErrorInfo GetErrorInfo( 996 [In] Int32 ulRecordNum, 997 [In] Int32 lcid); 998 GetErrorParameters( )999 [ Obsolete("not used", true)] void GetErrorParameters(/*deleted parameter signature*/); 1000 GetRecordCount()1001 Int32 GetRecordCount(); 1002 } 1003 #if false 1004 MIDL_INTERFACE("0c733a67-2a1c-11ce-ade5-00aa0044773d") 1005 IErrorRecords : public IUnknown AddErrorRecord( ERRORINFO *pErrorInfo, DWORD dwLookupID, DISPPARAMS *pdispparams, IUnknown *punkCustomError, DWORD dwDynamicErrorID)1006 virtual /* [local] */ HRESULT STDMETHODCALLTYPE AddErrorRecord( 1007 /* [in] */ ERRORINFO *pErrorInfo, 1008 /* [in] */ DWORD dwLookupID, 1009 /* [in] */ DISPPARAMS *pdispparams, 1010 /* [in] */ IUnknown *punkCustomError, 1011 /* [in] */ DWORD dwDynamicErrorID) = 0; GetBasicErrorInfo( ULONG ulRecordNum, ERRORINFO *pErrorInfo)1012 virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetBasicErrorInfo( 1013 /* [in] */ ULONG ulRecordNum, 1014 /* [out] */ ERRORINFO *pErrorInfo) = 0; GetCustomErrorObject( ULONG ulRecordNum, REFIID riid, IUnknown **ppObject)1015 virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetCustomErrorObject( 1016 /* [in] */ ULONG ulRecordNum, 1017 /* [in] */ REFIID riid, 1018 /* [iid_is][out] */ IUnknown **ppObject) = 0; GetErrorInfo( ULONG ulRecordNum, LCID lcid, IErrorInfo **ppErrorInfo)1019 virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetErrorInfo( 1020 /* [in] */ ULONG ulRecordNum, 1021 /* [in] */ LCID lcid, 1022 /* [out] */ IErrorInfo **ppErrorInfo) = 0; GetErrorParameters( ULONG ulRecordNum, DISPPARAMS *pdispparams)1023 virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetErrorParameters( 1024 /* [in] */ ULONG ulRecordNum, 1025 /* [out] */ DISPPARAMS *pdispparams) = 0; GetRecordCount( ULONG *pcRecords)1026 virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetRecordCount( 1027 /* [out] */ ULONG *pcRecords) = 0; 1028 #endif 1029 1030 [Guid("0C733A90-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 1031 internal interface IMultipleResults { 1032 1033 /*[local] 1034 HRESULT GetResult( 1035 [in] IUnknown * pUnkOuter, 1036 [in] DBRESULTFLAG lResultFlag, 1037 [in] REFIID riid, 1038 [out] DBROWCOUNT * pcRowsAffected, 1039 [out, iid_is(riid)] IUnknown ** ppRowset 1040 );*/ GetResult( [In] IntPtr pUnkOuter, [In] IntPtr lResultFlag, [In] ref Guid riid, [Out] out IntPtr pcRowsAffected, [Out, MarshalAs(UnmanagedType.Interface)] out object ppRowset)1041 [PreserveSig] System.Data.OleDb.OleDbHResult GetResult( 1042 [In] IntPtr pUnkOuter, 1043 [In] IntPtr lResultFlag, 1044 [In] ref Guid riid, 1045 [Out] out IntPtr pcRowsAffected, 1046 [Out, MarshalAs(UnmanagedType.Interface)] out object ppRowset); 1047 } 1048 #if false 1049 enum DBRESULTFLAGENUM { 1050 DBRESULTFLAG_DEFAULT = 0, 1051 DBRESULTFLAG_ROWSET = 1, 1052 DBRESULTFLAG_ROW = 2 1053 } 1054 MIDL_INTERFACE("0c733a90-2a1c-11ce-ade5-00aa0044773d") 1055 IMultipleResults : public IUnknown GetResult( IUnknown *pUnkOuter, DBRESULTFLAG lResultFlag, REFIID riid, DBROWCOUNT *pcRowsAffected, IUnknown **ppRowset)1056 virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetResult( 1057 /* [in] */ IUnknown *pUnkOuter, 1058 /* [in] */ DBRESULTFLAG lResultFlag, 1059 /* [in] */ REFIID riid, 1060 /* [out] */ DBROWCOUNT *pcRowsAffected, 1061 /* [iid_is][out] */ IUnknown **ppRowset) = 0; 1062 #endif 1063 1064 [Guid("0C733A69-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 1065 internal interface IOpenRowset { 1066 OpenRowset( [In] IntPtr pUnkOuter, [In] System.Data.OleDb.tagDBID pTableID, [In] IntPtr pIndexID, [In] ref Guid riid, [In] int cPropertySets, [In] IntPtr rgPropertySets, [Out, MarshalAs(UnmanagedType.Interface)] out object ppRowset)1067 [PreserveSig] System.Data.OleDb.OleDbHResult OpenRowset( 1068 [In] IntPtr pUnkOuter, 1069 [In] System.Data.OleDb.tagDBID pTableID, 1070 [In] IntPtr pIndexID, 1071 [In] ref Guid riid, 1072 [In] int cPropertySets, 1073 [In] IntPtr rgPropertySets, 1074 [Out, MarshalAs(UnmanagedType.Interface)] out object ppRowset); 1075 } 1076 1077 [Guid("0C733AB4-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 1078 internal interface IRow { 1079 GetColumns( [In] IntPtr cColumns, [In, Out, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.Struct)] System.Data.OleDb.tagDBCOLUMNACCESS[] rgColumns)1080 [PreserveSig] System.Data.OleDb.OleDbHResult GetColumns( 1081 [In] IntPtr cColumns, 1082 [In, Out, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.Struct)] System.Data.OleDb.tagDBCOLUMNACCESS[] rgColumns); 1083 1084 //[ Obsolete("not used", true)] void GetSourceRowset(/*deleted parameter signature*/); 1085 //[ Obsolete("not used", true)] void Open(/*deleted parameter signature*/); 1086 } 1087 1088 [Guid("0C733A7C-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 1089 internal interface IRowset { 1090 AddRefRows( )1091 [ Obsolete("not used", true)] void AddRefRows(/*deleted parameter signature*/); 1092 1093 /*HRESULT GetData( 1094 [in] HROW hRow, 1095 [in] HACCESSOR hAccessor, 1096 [out] void * pData 1097 );*/ GetData( [In] IntPtr hRow, [In] IntPtr hAccessor, [In] IntPtr pData)1098 [PreserveSig] System.Data.OleDb.OleDbHResult GetData( 1099 [In] IntPtr hRow, 1100 [In] IntPtr hAccessor, 1101 [In] IntPtr pData); 1102 1103 /*HRESULT GetNextRows( 1104 [in] HCHAPTER hReserved, 1105 [in] DBROWOFFSET lRowsOffset, 1106 [in] DBROWCOUNT cRows, 1107 [out] DBCOUNTITEM * pcRowsObtained, 1108 [out, size_is(,cRows)] HROW ** prghRows 1109 );*/ GetNextRows( [In] IntPtr hChapter, [In] IntPtr lRowsOffset, [In] IntPtr cRows, [Out] out IntPtr pcRowsObtained, [In] ref IntPtr pprghRows)1110 [PreserveSig] System.Data.OleDb.OleDbHResult GetNextRows( 1111 [In] IntPtr hChapter, 1112 [In] IntPtr lRowsOffset, 1113 [In] IntPtr cRows, 1114 [Out] out IntPtr pcRowsObtained, 1115 [In] ref IntPtr pprghRows); 1116 1117 /*HRESULT ReleaseRows( 1118 [in] DBCOUNTITEM cRows, 1119 [in, size_is(cRows)] const HROW rghRows[], 1120 [in, size_is(cRows)] DBROWOPTIONS rgRowOptions[], 1121 [out, size_is(cRows)] DBREFCOUNT rgRefCounts[], 1122 [out, size_is(cRows)] DBROWSTATUS rgRowStatus[] 1123 );*/ ReleaseRows( [In] IntPtr cRows, [In] SafeHandle rghRows, [In ] IntPtr rgRowOptions, [In ] IntPtr rgRefCounts, [In ] IntPtr rgRowStatus)1124 [PreserveSig] System.Data.OleDb.OleDbHResult ReleaseRows( 1125 [In] IntPtr cRows, 1126 [In] SafeHandle rghRows, 1127 [In/*, MarshalAs(UnmanagedType.LPArray)*/] IntPtr/*int[]*/ rgRowOptions, 1128 [In/*, Out, MarshalAs(UnmanagedType.LPArray)*/] IntPtr/*int[]*/ rgRefCounts, 1129 [In/*, Out, MarshalAs(UnmanagedType.LPArray)*/] IntPtr/*int[]*/ rgRowStatus); 1130 RestartPosition( )1131 [ Obsolete("not used", true)] void RestartPosition(/*deleted parameter signature*/); 1132 } 1133 1134 [Guid("0C733A55-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 1135 internal interface IRowsetInfo { 1136 1137 /*[local] 1138 HRESULT GetProperties( 1139 [in] const ULONG cPropertyIDSets, 1140 [in, size_is(cPropertyIDSets)] const DBPROPIDSET rgPropertyIDSets[], 1141 [in, out] ULONG * pcPropertySets, 1142 [out, size_is(,*pcPropertySets)] DBPROPSET ** prgPropertySets 1143 );*/ GetProperties( [In] int cPropertyIDSets, [In] SafeHandle rgPropertyIDSets, [Out] out int pcPropertySets, [Out] out IntPtr prgPropertySets)1144 [PreserveSig] System.Data.OleDb.OleDbHResult GetProperties( 1145 [In] int cPropertyIDSets, 1146 [In] SafeHandle rgPropertyIDSets, 1147 [Out] out int pcPropertySets, 1148 [Out] out IntPtr prgPropertySets); 1149 GetReferencedRowset( [In] IntPtr iOrdinal, [In] ref Guid riid, [Out, MarshalAs(UnmanagedType.Interface)] out IRowset ppRowset)1150 [PreserveSig] System.Data.OleDb.OleDbHResult GetReferencedRowset( 1151 [In] IntPtr iOrdinal, 1152 [In] ref Guid riid, 1153 [Out, MarshalAs(UnmanagedType.Interface)] out IRowset ppRowset); 1154 1155 //[PreserveSig] 1156 //int GetSpecification(/*deleted parameter signature*/); 1157 } 1158 1159 [Guid("0C733A74-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 1160 internal interface ISQLErrorInfo { 1161 GetSQLInfo( [Out, MarshalAs(UnmanagedType.BStr)] out String pbstrSQLState)1162 [return:MarshalAs(UnmanagedType.I4)] Int32 GetSQLInfo( 1163 [Out, MarshalAs(UnmanagedType.BStr)] out String pbstrSQLState); 1164 } 1165 1166 [Guid("0C733A5F-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity] 1167 internal interface ITransactionLocal { 1168 Commit( )1169 [ Obsolete("not used", true)] void Commit(/*deleted parameter signature*/); 1170 Abort( )1171 [ Obsolete("not used", true)] void Abort(/*deleted parameter signature*/); 1172 GetTransactionInfo( )1173 [ Obsolete("not used", true)] void GetTransactionInfo(/*deleted parameter signature*/); 1174 GetOptionsObject( )1175 [ Obsolete("not used", true)] void GetOptionsObject(/*deleted parameter signature*/); 1176 1177 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] StartTransaction( [In] int isoLevel, [In] int isoFlags, [In] IntPtr pOtherOptions, [Out] out int pulTransactionLevel)1178 [PreserveSig] System.Data.OleDb.OleDbHResult StartTransaction( 1179 [In] int isoLevel, 1180 [In] int isoFlags, 1181 [In] IntPtr pOtherOptions, 1182 [Out] out int pulTransactionLevel); 1183 } 1184 1185 // we wrap the vtable entry which is just a function pointer as a delegate 1186 // since code (unlike data) doesn't move around within the process, it is safe to cache the delegate 1187 1188 // we do not expect native to change its vtable entry at run-time (especially since these are free-threaded objects) 1189 // however to be extra safe double check the function pointer is the same as the cached delegate 1190 // whenever we encounter a new instance of the data 1191 1192 1193 // dangerous delegate around IUnknown::QueryInterface (0th vtable entry) 1194 [System.Security.SuppressUnmanagedCodeSecurityAttribute()] IUnknownQueryInterface( IntPtr pThis, ref Guid riid, ref IntPtr ppInterface)1195 internal delegate int IUnknownQueryInterface( 1196 IntPtr pThis, 1197 ref Guid riid, 1198 ref IntPtr ppInterface); 1199 1200 // dangerous delegate around IDataInitialize::GetDataSource (4th vtable entry) 1201 [System.Security.SuppressUnmanagedCodeSecurityAttribute()] IDataInitializeGetDataSource( IntPtr pThis, IntPtr pUnkOuter, int dwClsCtx, [MarshalAs(UnmanagedType.LPWStr)] string pwszInitializationString, ref Guid riid, ref System.Data.OleDb.DataSourceWrapper ppDataSource)1202 internal delegate System.Data.OleDb.OleDbHResult IDataInitializeGetDataSource( 1203 IntPtr pThis, // first parameter is always the 'this' value, must use use result from QI 1204 IntPtr pUnkOuter, 1205 int dwClsCtx, 1206 [MarshalAs(UnmanagedType.LPWStr)] string pwszInitializationString, 1207 ref Guid riid, 1208 ref System.Data.OleDb.DataSourceWrapper ppDataSource); 1209 1210 // dangerous wrapper around IDBInitialize::Initialize (4th vtable entry) 1211 [System.Security.SuppressUnmanagedCodeSecurityAttribute()] IDBInitializeInitialize( IntPtr pThis)1212 internal delegate System.Data.OleDb.OleDbHResult IDBInitializeInitialize( 1213 IntPtr pThis); // first parameter is always the 'this' value, must use use result from QI 1214 1215 // dangerous wrapper around IDBCreateSession::CreateSession (4th vtable entry) 1216 [System.Security.SuppressUnmanagedCodeSecurityAttribute()] IDBCreateSessionCreateSession( IntPtr pThis, IntPtr pUnkOuter, ref Guid riid, ref System.Data.OleDb.SessionWrapper ppDBSession)1217 internal delegate System.Data.OleDb.OleDbHResult IDBCreateSessionCreateSession( 1218 IntPtr pThis, // first parameter is always the 'this' value, must use use result from QI 1219 IntPtr pUnkOuter, 1220 ref Guid riid, 1221 ref System.Data.OleDb.SessionWrapper ppDBSession); 1222 1223 // dangerous wrapper around IDBCreateCommand::CreateCommand (4th vtable entry) 1224 [System.Security.SuppressUnmanagedCodeSecurityAttribute()] IDBCreateCommandCreateCommand( IntPtr pThis, IntPtr pUnkOuter, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] ref object ppCommand)1225 internal delegate System.Data.OleDb.OleDbHResult IDBCreateCommandCreateCommand( 1226 IntPtr pThis, // first parameter is always the 'this' value, must use use result from QI 1227 IntPtr pUnkOuter, 1228 ref Guid riid, 1229 [MarshalAs(UnmanagedType.Interface)] ref object ppCommand); 1230 #endif 1231 1232 // 1233 // Advapi32.dll Integrated security functions 1234 // 1235 1236 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 1237 internal struct Trustee { 1238 internal IntPtr _pMultipleTrustee; // PTRUSTEE 1239 internal int _MultipleTrusteeOperation; // MULTIPLE_TRUSTEE_OPERATION 1240 internal int _TrusteeForm; // TRUSTEE_FORM 1241 internal int _TrusteeType; // TRUSTEE_TYPE 1242 [MarshalAs(UnmanagedType.LPTStr)] 1243 internal string _name; 1244 TrusteeSystem.Data.Common.UnsafeNativeMethods.Trustee1245 internal Trustee(string name) { 1246 _pMultipleTrustee = IntPtr.Zero; 1247 _MultipleTrusteeOperation = 0; // NO_MULTIPLE_TRUSTEE 1248 _TrusteeForm = 1; // TRUSTEE_IS_NAME 1249 _TrusteeType = 1; // TRUSTEE_IS_USER 1250 _name = name; 1251 } 1252 } 1253 1254 [DllImport(ExternDll.Advapi32, CharSet=CharSet.Unicode)] 1255 [ResourceExposure(ResourceScope.None)] GetEffectiveRightsFromAclW(byte[] pAcl, ref Trustee pTrustee, out uint pAccessMask)1256 static internal extern uint GetEffectiveRightsFromAclW (byte[] pAcl, ref Trustee pTrustee, out uint pAccessMask); 1257 1258 [DllImport(ExternDll.Advapi32, SetLastError=true)] 1259 [ResourceExposure(ResourceScope.None)] 1260 [return:MarshalAs(UnmanagedType.Bool)] CheckTokenMembership(IntPtr tokenHandle, byte[] sidToCheck, out bool isMember)1261 static internal extern bool CheckTokenMembership (IntPtr tokenHandle, byte[] sidToCheck, out bool isMember); 1262 1263 [DllImport(ExternDll.Advapi32, SetLastError=true)] 1264 [ResourceExposure(ResourceScope.None)] 1265 [return:MarshalAs(UnmanagedType.Bool)] ConvertSidToStringSidW(IntPtr sid, out IntPtr stringSid)1266 static internal extern bool ConvertSidToStringSidW(IntPtr sid, out IntPtr stringSid); 1267 1268 [DllImport(ExternDll.Advapi32, EntryPoint="CreateWellKnownSid", SetLastError=true, CharSet=CharSet.Unicode)] 1269 [ResourceExposure(ResourceScope.None)] CreateWellKnownSid( int sidType, byte[] domainSid, [Out] byte[] resultSid, ref uint resultSidLength )1270 static internal extern int CreateWellKnownSid( 1271 int sidType, 1272 byte[] domainSid, 1273 [Out] byte[] resultSid, 1274 ref uint resultSidLength ); 1275 1276 [DllImport(ExternDll.Advapi32, SetLastError=true)] 1277 [ResourceExposure(ResourceScope.None)] 1278 [return:MarshalAs(UnmanagedType.Bool)] GetTokenInformation(IntPtr tokenHandle, uint token_class, IntPtr tokenStruct, uint tokenInformationLength, ref uint tokenString)1279 static internal extern bool GetTokenInformation(IntPtr tokenHandle, uint token_class, IntPtr tokenStruct, uint tokenInformationLength, ref uint tokenString); 1280 1281 [DllImport(ExternDll.Kernel32, CharSet=CharSet.Unicode)] 1282 [ResourceExposure(ResourceScope.None)] lstrlenW(IntPtr ptr)1283 internal static extern int lstrlenW(IntPtr ptr); 1284 1285 /* For debugging purposes... 1286 [DllImport(ExternDll.Advapi32)] 1287 [return:MarshalAs(UnmanagedType.I4)] 1288 static internal extern int GetLengthSid(IntPtr sid1); 1289 */ 1290 } 1291 } 1292