OleDbType Enumeration

OleDbType Enumeration

Specifies the data type of a field, a property, for use in an OleDbParameter.

Namespace:   System.Data.OleDb
Assembly:   System.Data (in System.Data.dll)
Visual Basic (Declaration)
Public Enumeration OleDbType
Visual Basic (Usage)
Dim instance As OleDbType
C#
public enum OleDbType
Visual C++
public enum class OleDbType
JScript
public enum OleDbType

Member nameDescription

BigInt A 64-bit signed integer (DBTYPE_I8). This maps to Int64.

Binary A stream of binary data (DBTYPE_BYTES). This maps to an Array of type Byte.

Boolean A Boolean value (DBTYPE_BOOL). This maps to Boolean.

BSTR A null-terminated character string of Unicode characters (DBTYPE_BSTR). This maps to String.

Char A character string (DBTYPE_STR). This maps to String.

Currency A currency value ranging from -2 63 (or -922,337,203,685,477.5808) to 2 63 -1 (or +922,337,203,685,477.5807) with an accuracy to a ten-thousandth of a currency unit (DBTYPE_CY). This maps to Decimal.

Date Date data, stored as a double (DBTYPE_DATE). The whole portion is the number of days since December 30, 1899, and the fractional portion is a fraction of a day. This maps to DateTime.

DBDate Date data in the format yyyymmdd (DBTYPE_DBDATE). This maps to DateTime.

DBTime Time data in the format hhmmss (DBTYPE_DBTIME). This maps to TimeSpan.

DBTimeStamp Data and time data in the format yyyymmddhhmmss (DBTYPE_DBTIMESTAMP). This maps to DateTime.

Decimal A fixed precision and scale numeric value between -10 38 -1 and 10 38 -1 (DBTYPE_DECIMAL). This maps to Decimal.

Double A floating-point number within the range of -1.79E +308 through 1.79E +308 (DBTYPE_R8). This maps to Double.

Empty No value (DBTYPE_EMPTY).

Error A 32-bit error code (DBTYPE_ERROR). This maps to Exception.

Filetime A 64-bit unsigned integer representing the number of 100-nanosecond intervals since January 1, 1601 (DBTYPE_FILETIME). This maps to DateTime.

Guid A globally unique identifier (or GUID) (DBTYPE_GUID). This maps to Guid.

IDispatch A pointer to an IDispatch interface (DBTYPE_IDISPATCH). This maps to Object.

Integer A 32-bit signed integer (DBTYPE_I4). This maps to Int32.

IUnknown A pointer to an IUnknown interface (DBTYPE_UNKNOWN). This maps to Object.

LongVarBinary A long binary value (OleDbParameter only). This maps to an Array of type Byte.

LongVarChar A long string value (OleDbParameter only). This maps to String.

LongVarWChar A long null-terminated Unicode string value (OleDbParameter only). This maps to String.

Numeric An exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC). This maps to Decimal.

PropVariant An automation PROPVARIANT (DBTYPE_PROP_VARIANT). This maps to Object.

Single A floating-point number within the range of -3.40E +38 through 3.40E +38 (DBTYPE_R4). This maps to Single.

SmallInt A 16-bit signed integer (DBTYPE_I2). This maps to Int16.

TinyInt A 8-bit signed integer (DBTYPE_I1). This maps to SByte.

UnsignedBigInt A 64-bit unsigned integer (DBTYPE_UI8). This maps to UInt64.

UnsignedInt A 32-bit unsigned integer (DBTYPE_UI4). This maps to UInt32.

UnsignedSmallInt A 16-bit unsigned integer (DBTYPE_UI2). This maps to UInt16.

UnsignedTinyInt A 8-bit unsigned integer (DBTYPE_UI1). This maps to Byte.

VarBinary A variable-length stream of binary data (OleDbParameter only). This maps to an Array of type Byte.

VarChar A variable-length stream of non-Unicode characters (OleDbParameter only). This maps to String.

Variant A special data type that can contain numeric, string, binary, or date data, and also the special values Empty and Null (DBTYPE_VARIANT). This type is assumed if no other is specified. This maps to Object.

VarNumeric A variable-length numeric value (OleDbParameter only). This maps to Decimal.

VarWChar A variable-length, null-terminated stream of Unicode characters (OleDbParameter only). This maps to String.

WChar A null-terminated stream of Unicode characters (DBTYPE_WSTR). This maps to String.

The preceding table shows mappings between OleDbType data types, OLE DB data types (shown in parentheses), and the .NET Framework types. The OleDbType data types accept System.Char[]as Parameter.Value in parameterized queries.

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0, 1.1, 1.0


From:
http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbtype.aspx
OleDbDataAdapter可以通过以下步骤来修改数据: 1. 创建一个OleDbConnection对象并打开连接。 2. 创建一个OleDbDataAdapter对象并设置其SelectCommand属性为SELECT语句,用于获取要修改的数据。 3. 创建一个DataSet对象并使用OleDbDataAdapter的Fill方法填充数据。 4. 在DataSet中修改数据。 5. 创建一个OleDbCommandBuilder对象并设置其DataAdapter属性为OleDbDataAdapter对象。 6. 调用OleDbDataAdapter的Update方法,将修改后的数据保存到数据库中。 以下是示例代码: ```csharp string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Northwind.mdb"; string selectCommand = "SELECT * FROM Customers"; string updateCommand = "UPDATE Customers SET CompanyName = ?, ContactName = ?, City = ? WHERE CustomerID = ?"; // 创建OleDbConnection对象并打开连接 using (OleDbConnection connection = new OleDbConnection(connectionString)) { connection.Open(); // 创建OleDbDataAdapter对象并设置SelectCommand属性 OleDbDataAdapter adapter = new OleDbDataAdapter(selectCommand, connection); // 创建DataSet对象并使用OleDbDataAdapter的Fill方法填充数据 DataSet dataSet = new DataSet(); adapter.Fill(dataSet, "Customers"); // 在DataSet中修改数据 DataRow row = dataSet.Tables["Customers"].Rows[0]; row["CompanyName"] = "New Company"; row["ContactName"] = "New Contact"; row["City"] = "New York"; // 创建OleDbCommandBuilder对象并设置DataAdapter属性 OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(adapter); // 调用OleDbDataAdapter的Update方法,将修改后的数据保存到数据库中 adapter.UpdateCommand = new OleDbCommand(updateCommand, connection); adapter.UpdateCommand.Parameters.Add("@CompanyName", OleDbType.VarChar, 40, "CompanyName"); adapter.UpdateCommand.Parameters.Add("@ContactName", OleDbType.VarChar, 30, "ContactName"); adapter.UpdateCommand.Parameters.Add("@City", OleDbType.VarChar, 15, "City"); adapter.UpdateCommand.Parameters.Add("@CustomerID", OleDbType.VarChar, 5, "CustomerID"); adapter.Update(dataSet, "Customers"); } ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值