易截截图软件、单文件、免安装、纯绿色、仅160KB

Access数据库转换为sdf数据库及SqlCeHelper类

在做Mobile项目时遇到一个问题,我们的Mobile项目需要使用SqlCe数据库,而客户提供的带有原始数据的数据库是Access格式的,所以我们面临的第一个问题是将Access数据库(*.mdb)转换成SqlCe数据库(*.sdf)。网上搜索的很多资料是关于如何将SqlServer 2005与SqlCe数据进行同步,主要是通过发布订阅及RDA编程来实现,可以参考的资料有:
用 SQL Server Management Studio 管理 SQL Server Compact Edition 数据库
SQL CE 和 SQL Server 的同步
Step by Step: Program Microsoft SQL Server CE 2.0 Merge Replication Using .NET Compact Framework
    后来找到一个工具Data Port Wizard可以直接将其他数据库转换为SqlCe数据库,省了不少事。只是转换过程中遇到一个小小的问题,在客户提供的Access数据库的关系里设置了很多表与表之间的关系,但所有的表都没有设置主键,所以转换时就抛出异常。为了省事,我将Access表的关系全部删除,这样就顺利的将Access数据库转换成SqlCe 3.5版本的sdf数据库了。
    至于操作SqlCe的数据层的类,在网上找到一个SqlCeHelper.cs,转贴如下:
using System;
using System.Data;
using System.Data.SqlServerCe;
using System.Configuration;
using System.Collections;
namespace SbuxMobile.DAL
{
///
/// The SqlCeHelper class is intended to encapsulate high performance, scalable best practices for
/// common uses of SqlClient
///
public sealed partial class SqlCeHelper
{
#region private utility methods & constructors
// Since this class provides only static methods, make the default constructor private to prevent
// instances from being created with "new SqlCeHelper()"
private SqlCeHelper() { }
///
/// This method is used to attach array of SqlCeParameters to a SqlCeCommand.
///
/// This method will assign a value of DbNull to any parameter with a direction of
/// InputOutput and a value of null.
///
/// This behavior will prevent default values from being used, but
/// this will be the less common case than an intended pure output pa


相关文档:

ADO数据库连接Access

创建基于对话框的应用程序ADO,向对话框中添加一个列表视图控件,并为其添加变量m_Grid
第一步:ADO对象的导入
在StdAfx.h头文件中:
// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, bu
//      are ......

OleDbType 枚举与 Microsoft Access 数据类型

最常见的数据类型映射的列表
下表列出了在 Microsoft Access 和如何这些数据类型与相关 Microsoft.net 框架数据类型,并 OleDbType 枚举中使用最常见的数据类型。
收起该表格展开该表格
访问类型名称
数据库数据类型
OLE DB 类型
.NET 框架类型
成员名称
文本
VarWChar
DBTYPE_WSTR
System.String
OleDbType.V ......

Image To Access

using System;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace ImageDB
{
    public partial class FormImageAccess : Form
    {
        #region 自定义对象 ......

access常用函数

每个函数都可以将表达式 (表达式:算术或逻辑运算符、常数、函数和字段名称、控件和属性的任意组合,计算结果为单个值。表达式可执行计算、操作字符或测试数据。)强制转换为特定的数据类型 (数据类型:决定字段可拥有的数据类型的字段特征。数据类型包括 Boolean、Integer、Long、Currency、Single、Double、Date、Strin ......

access IIf函数

根据表达式的值,来返回两部分中的其中一个。 
  
语法   
IIf(expr,   truepart,   falsepart)  
 
IIf   函数的语法含有下面这些命名参数: 
  
部分   描述    
expr   必 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号