Sub adddata() Dim mydb As Database Dim mydbname As String mydbname = "abc.mdb" Set mydb = Workspaces(0).OpenDatabase(mydbname)
Dim mydbe As DAO.DBEngine Set mydbe = New DAO.DBEngine Dim mytbl As TableDef Dim mytablename As String mytablename = "efg"
Dim myrec As Recordset Set myrec = mydb.OpenRecordset(mytablename,DAO.RecordsetTypeEnum.dbOpenDynaset)
myrec.AddNew myrec.Fields(0).Value = 1 myrec.Fields(1).Value = 2 myrec.Fields(2).Value = 3 myrec.Fields(3).Value = 4 myrec.Fields(4).Value = 5 myrec.Fields(5).Value = 6 myrec.Fields(6).Value = 7 myrec.Fields(7).Value = 8 myrec.Fields(8).Value = 9 myrec.Update mydb.Close
End Sub 上面这段子程序中,已经在相应的目录下创建了数据库“abd”,现在要通过调用该段程序向数据库中添加数据 ,可是在运行过程中,红色行显示为“类型不匹配”,不知问题出在什么地方,请帮忙看看。 |