引用:microsoft activex data objects2.x library和microsoft ado ext.2.x for ddl and securityVRP检测VBA 代码:VRP检测VBA public sub1_6()VRP检测VBA dim mycat as new adox.catalog ‘定义adox的catalog对象变量VRP检测VBA dim mycmd as new adodb.command ‘定义command对象变量VRP检测VBA dim mydata as string ‘定义数据库名称变量VRP检测VBA dim mytable as string ‘定义数据表名称变量VRP检测VBA dim sql as string VRP检测VBA ‘设置数据库名称(包括完整路径)VRP检测VBA mydata=thisworkbook.path & “\学生成绩管理.mdb”VRP检测VBA ‘设置要创建的数据表名称VRP检测VBA mytable=”期末成绩”VRP检测VBA ‘建立与数据库的连接VRP检测VBA mycat.activeconnection=”provider=microsoft.jet.oledb.4.0;”_VRP检测VBA & “data source=” & mydataVRP检测VBA ‘删除数据库中已经存在的数据表VRP检测VBA mycat.tables.delete mytableVRP检测VBA ‘设置数据库连接VRP检测VBA set mycmd.activeconnection=mycat.activeconnectionVRP检测VBA ‘设置创建数据表的SQL语句VRP检测VBA SQL=”CREATE TABLE” & mytable_VRP检测VBA & “(学号 text(10),姓名 text(6),性别 text(1),班级 text(10),” _VRP检测VBA & “数学 single,语文 single,物理 single,化学 single, “_VRP检测VBA & “英语 single,总分 single)”VRP检测VBA ‘利用Execute方法创建数据表VRP检测VBA With mycmdVRP检测VBA .commandtext=sqlVRP检测VBA .execute, , adcmdtextVRP检测VBA End withVRP检测VBA ‘释放变量VRP检测VBA Set mycat=nothingVRP检测VBA Set mycmd=nothingVRP检测VBA ‘弹出信息VRP检测VBA Msgbox “数据表<” & mytable & “>创建成功!”,vbinformation,”创建数据表”VRP检测VBA