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