【问题标题】:comparing data type of sql server and ms access in c#比较c#中sql server和ms访问的数据类型
【发布时间】:2011-12-10 04:26:03
【问题描述】:

有什么方法可以比较两个不同数据库的数据类型。

【问题讨论】:

  • 建议:使用单一数据提供者(OleDB)读写不同数据库的行。
  • 我不能只使用 OleDb 提供程序来读写不同的数据库,因为它与 64 位操作系统存在兼容性问题。
  • 您想使用哪个提供商来访问 Ms-Acces?是 ODBC 吗?
  • 对于访问它是 ODBC,对于 Oracle 和 SqlServer 它是 ADO.NET。
  • 同时在 OLE DB 上进行整合是个坏主意,因为 Microsoft 正在淘汰 SQL Server 中的 OLE DB。

标签: c# sql-server ms-access ado.net


【解决方案1】:
Jet Engine (Access) | Sql-Server                          | C#
--------------------+-------------------------------------+--------------------
Text (len < 256)    | char, nchar, varchar, nvarchar      | string
Memo                | text, ntext, the above with len>255 | string
Byte                | tinyint                             | byte
Integer             | smallint                            | short
Long Integer        | integer (int)                       | int
Single              | real                                | float
Double              | float                               | double
Replication ID      | uniqueidentifier                    | Guid
Decimal             | decimal                             | decimal
Date/Time           | smalldatetime, datetime, datetime2  | DateTime
Binary     (8 bytes)| timestamp, rowversion (Since V2008) | byte[]    (8 bytes)
Currency            | smallmoney, money                   | decimal
AutoNumber          | int + identity property             | int
Yes/No              | bit                                 | bool
OLE Object          | image                               | byte[]
Hyperlink           | <no equivalent>                     | string
<no equivalent>     | binary, varbinary                   | byte[]

我从How to Migrate from Access to SQL Server 2000 获取了这些信息并添加了 c# 列。

还要注意,大多数类型在数据库中都是可以为空的。将可空列映射到 C# 中的 Nullable&lt;T&gt; (T?),除非 .NET 类型是引用类型。

【讨论】:

  • 感谢 Olivier,我会使用它,然后让您知道它是否适合我。
猜你喜欢
  • 1970-01-01
  • 2013-04-02
  • 1970-01-01
  • 2013-10-05
  • 1970-01-01
  • 1970-01-01
  • 2011-08-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多