| 发表于:2007-10-24 08:44:553楼 得分:20 |
我是用的ado,首先引用 microsoft activex dataobjects 2.8library 和 microsoft activex dataobjects 2.8library 以下是代码: dim str as string dim con as new adodb.connection dim rst as new adodb.recordset dim str_first as string dim str_second as string dim str_third as string str = "provider=microsoft.jet.oledb.4.0;data source=d:\lala\db2.mdb;persist security info=false" '数据库连接字符串 con.open str ' 打开access数据库 str = "select first,second,third from biao" rst.open str, con ' 打开记录集 do until rst.eof str_first = rst!first '将字段值读入变量中 str_second = rst!second str_third = rst!third rst.movenext loop rst.close '关闭记录集 rst.open str, con, adopenkeyset, adlockoptimistic '打开用于更新的记录集,注意adopenkeyset, adlockoptimistic 两个参数。 rst.addnew '向表中添加数据 rst!first = "" rst!second = "" rst!third = """" rst.update rst.close ' con.close '关闭数据库 | | |
|