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

VC/MFC中的ACCESS数据库访问实现(方法3)

接 2
方法3 :
这种方法也需要用户自己创建一个数据源,但是,所需要进行的步骤,比方法2要少上许多。
创建好用户表。
创建数据源(控制面板->数据管理->数据源 双击 -> 选择 文件 DSN -> 添加 -> Microsoft Access Driver -> 手动输入DSN 保存的位置及名称 -> 选择(S) 并选中所创建好的数据库文件 -> 确定 -> 确定 ... 完成 )
创建一个基于MFC对话框的工程。其他工程也可。
在主窗口的函数头部加入 #include <afxdb.h>
为主程序定义一全局变量 CDatabase cdb1 ;
在出窗口的初始化出加入如下代码:
cdb1.open("那会创建的数据源名称");
为主窗口添加一个按钮,并添加按钮的相应函数。
在响应函数中的处理代码如下:
CString strTmp = "Insert into mydb(SUserName, SSex) values ('李四','男')";
cdb1.ExecuteSQL(strTmp);
这样的话,第三种方法也结束了。
PS:
对于CDatabase 类 ,如果想详细了解的话,可以到网上去搜索下。
对于类里面的Open()方法,这里有一个连接是对他进行讲解的
      http://www.sunxin.org/article/1042.html 


相关文档:

VB.NET压缩ACCESS数据库

'创建数据库
  Private Sub Create(ByVal mdbPath As String)
        If File.Exists(mdbPath) Then
            Throw New Exception("目标数据库已经存在,无法创建")
        ......

C#读取access表,并把数据显示在gridcontrol中

 //读取标准列表
        private void setModelList()
        {
            OleDbConnection Connection = null;
         &n ......

Access Web System from external

Take Equity Collection System as an example, Some other office collegues want to access it from home without VPN, The way to check is:
1.  Check if it's limited in network, this needs to confirm with network people
2.  If the step 1 passed, get the external IP address of the system, map ......

c#操作access数据库

 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace AddressList
{
public partial class FrmAccessUse : Form
{
public Fr ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号