' -----------------------------read db

Private Sub Form_Load()

'MsgBox App.Path & "\wgscd.mdb"

Dim tblCountry As Recordset

Dim dbSys As Database

Dim s As String

Set dbSys = OpenDatabase(App.Path + "\wgscd.mdb", False)

Set tblCountry = dbSys.OpenRecordset("Students")' OR Use like : dbSys.OpenRecordset("select * from Students")

With tblCountry

.MoveFirst

Do While Not .EOF

s = s & !sid & ";" & !Name & " score:" & .Fields("score") 'note:"!sid" is present as .Fields("sid")

.MoveNext

Loop

End With
MsgBox s

End Sub

'--------------write db-----------------------------

Private Sub Command1_Click()

'MsgBox App.Path & "\wgscd.mdb"

Dim tblCountry As Recordset

Dim dbSys As Database

Dim s As String

Set dbSys = OpenDatabase(App.Path + "\wgscd.mdb", False)

Set tblCountry = dbSys.OpenRecordset("Students")

With tblCountry

.AddNew

!sid = 5 + rnd(500)

!Name = "bb" & Now

.Fields("score") = rnd(100)

.Update

.MoveFirst

End With

 MsgBox tblCountry.RecordCount

End Sub


bind data with TDBGrid (Library TrueDBGrid80 C:\WINDOWS\system32\tdbg8.oca ComponentOne True DBGrid Pro 8.0)

step:

1.Drag a Data control to the form with named "Data1"

2.Drag a TDBGrid control to the form with named "TDBGrid1"

2.Set control "TDBGrid1"'s property "DataSource" with value "Data1"

3.hen code :

Dim sysDb As Database

Private Sub Command1_Click()

Dim rsData As Recordset

Dim sPath As String

Dim rs As Recordset

sPath = App.Path + "/testDB.mdb"

Set sysDb = OpenDatabase(sPath, 3)

Set rsData = sysDb.OpenRecordset("select * from students")

Set rs = rsData.Clone

Set Data1.Recordset = rs 'must use set

TDBGrid1.Columns("id").BackColor = vbRed

'Me.TDBGrid1.ReBind

End Sub

refer link:

Database.OpenRecordset Method (DAO) link:https://msdn.microsoft.com/en-us/library/office/ff820966.aspx

VB6 red write DB using Microsoft DAO 3.6 Object Library的更多相关文章

  1. 在项目引用里添加上对Microsoft Word 11.0 object library的引用

    private void button1_Click(object sender, System.EventArgs e) { //调用打开文件对话框获取要打开的文件WORD文件,RTF文件,文本文件 ...

  2. Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: “object”未包括“get_Range”的定义

    asp.net操作Excel合并单元格时,抛出了异常: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: "object" ...

  3. java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.yunweather.app.db.YunWeatherDB.loadProvinces()' on a null object reference

    NullPointerException:查看自己的什么地方是否对空指针进行了操作 Attempt to invoke virtual method 'java.util.List com.yunwe ...

  4. go web开发(gin&gorm) 之DB配置及DAO的基本使用

    转载请注明出处: https://www.cnblogs.com/funnyzpc/p/9501376.html ```   我先闲扯下,前天(也就是2018年11月16号)的某个时候,忽然有人在QQ ...

  5. csharp: Procedure with DAO(Data Access Object) and DAL(Data Access Layer)

    sql script code: CREATE TABLE DuCardType ( CardTypeId INT IDENTITY(1,1) PRIMARY KEY, CardTypeName NV ...

  6. c#使用Microsoft Excel 12.0 object Libary导出的Excel文件office2003不能打开!!~~(分享)

    -----转载:http://hi.baidu.com/zhang_zhu_1/item/f3d47d1f86bf037a70d5e87e 使用C#导出数据到Excel文件时,Excel 2007组件 ...

  7. VB6 Access 事务(Transaction)

    VB6 Access 事务 On Error GoTo err_trans intTrans = conn.BeginTrans '开始事务 X = count For i = 0 To X sql= ...

  8. 使用VB6制作RTD函数

    以前模仿大神在vs里使用c#实现RTD函数功能.(真是很生僻的东东啊)C#制作RTD参考:大神博客跳转.最近想VB里能不能做?就试着做了做,好像基本成了,整套代码有些毛病,勉强能算个样子,暂时不打算再 ...

  9. 引用Microsoft.Office.Interop.Excel出现的问题

    引用Microsoft.Office.Interop.Excel出现的问题   转自:http://www.hccar.com/Content,2008,6,11,75.aspx,作者:方继祥 操作背 ...

随机推荐

  1. 网站换了HTTPS后残留部分http处理方式

    网站换了HTTPS后残留部分http处理方式,以前添加的文章里面是有http的,导致浏览器打开网站的时候提示证书不安全,解决方法很简单 在html页面上加上这一段话 <!-- 强制让http的访 ...

  2. CentOS随笔 - 5.CentOS7安装Sql Server 2017

    前言 转帖请注明出处: http://www.cnblogs.com/Troy-Lv5/ 开发环境嘛, 作为.Net系Sql Server那是必备的. 听过Sql server可以安装在Linux上了 ...

  3. [WINCE|VS2008] 用在PC上调试WINCE程序

    http://www.danielmoth.com/Blog/deploy-to-my-computer.aspx 作者:The Moth 步骤: 1. 在VS2008中打到 Device Optio ...

  4. Java 两个日期间的天数计算

    在Java中计算两个日期间的天数,大致有2种方法:一是使用原生JDK进行计算,在JDK8中提供了更为直接和完善的方法:二是使用第三方库. 1.使用原生的JDK private static long  ...

  5. SecureCRT ssh连接linux操作系统(解决Ubutu密钥交换失败的问题)

    我们可以使用终端软件SecureCRT 去连接linux操作系统(该SecureCRT服务走端口22,协议是ssh(类似apache走http协议,端口80)),SSH 为 Secure Shell ...

  6. 转载:从程序员的角度看ASCII, GB2312, UNICODE, UTF-8

    以下内容转自博客:http://blog.chinaunix.net/uid-22670933-id-1771613.html. 一.字符编码是怎么回事 0. 概念 字节是计算机的最基本存储单位,一个 ...

  7. 我的Java之旅——答答租车系统的改进

    之前的答答租车系统虽然可以实现项目的要求,但是没有用Java面向对象,今天用面向对象的三大特性封装.继承和多态来改进原来的代码.题目和之前的代码参考上篇博客,这里不再述说. 改进后的代码: Vehic ...

  8. 利用xlst导出多表头的简便方法

    大家都知道在ASP.NET中进行表格导出有很多种办法,aspose,npoi,cvs等等,今天就来介绍xlst,导出多表头.与以往不一样的是我们利用模板,只需要在模板中定义好表格样式,然后绑定数据就可 ...

  9. [装]JMX监控Hadoop

    http://chenjc-it.iteye.com/blog/1539746 实验成功!

  10. js检测密码强度

    <script> function AuthPasswd(string) {     if(string.length >=6) {         if(/[a-zA-Z]+/.t ...