易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

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 自定义对象 ......

ADO连接用户级加密的ACCESS数据库

 最近做个项目需要连接到一个第3方软件用到的MDB数据库,该MDB文件是用户级加密,虽然合作方给了用户名,说没有密码,但是却无法用ADO进行查询,报没有权限。用ACCESS打开也是一样,无法看到表里的数据。于是到网上去搜,结果只搜到如何用ACCESS对MDB进行加密和打开加密文件,这个跟编程无关,就没细看。关于ADO连接加 ......

Access 安全概述 (MDB)

注释  本主题中的信息仅适用于 Microsoft Access 数据库 (.mdb)。
有各种不同的策略用来控制对 Microsoft Access 数据库及其对象的访问级别。下面大致按照安全级别的顺序,简要介绍这些策略。
编码/解码
为数据库编码是最简单的保护方法。为数据库编码可压缩数据库文件,并帮助防止该文件被文字处理程序读取。但 ......

Excel and Access 97 2003、2007的连接串

下午在Excel导入SQL时,发现原连接Excel的数据连接串过时造成新的Excel格式*.xlsx无法识别。
把新的连接串替换~
分别测试03/07的Excel文件均可通过~
Office 97-2003版本
Excel:  Provider= Microsoft.Jet.OLEDB.4.0;Data Source=文件位置;Extended Properties=Excel 8.0;
Access: Provider= Microsoft.Jet.OLEDB ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号