在vb中动态创建数据库
新建工程.添加控件 对应写上代码
以下为引用的内容: private sub command2_click() dim mydb as dao.database 'set mydb = dao.opendatabase("d:/mydb3.mdb") set mydb = dao.opendatabase(app.path + "/mydb.mdb") dim d as string d = "delete * from newtable1" mydb.execute d msgbox "成功删除全部记录" end sub private sub command3_click() dim mydb as dao.database 'set mydb = dao.opendatabase("d:/mydb3.mdb") set mydb = dao.opendatabase(app.path + "/mydb.mdb") dim e as string e = "drop table newtable1" mydb.execute e end sub private sub form_load() dim mydb as dao.database 'set mydb = dao.workspaces(0).createdatabase("d:/mydb3.mdb", dblanggeneral) set mydb = dao.workspaces(0).createdatabase(app.path + "/mydb.mdb", dblanggeneral) dim str_sql as string str_sql = "create table newtable1(field1 text(10),field2 short)" mydb.execute str_sql dim a as string a = "insert into newtable1 values ('litao','21')" mydb.execute a str_sql = "create table newtable2(field1 text(10),field2 short)" mydb.execute str_sql mydb.close msgbox "成功创建mydb3.mdb数据库外加一条记录litao 21" end sub private sub command1_click() dim mydb as dao.database 'set mydb = dao.opendatabase("d:/mydb3.mdb") set mydb = dao.opendatabase(app.path + "/mydb.mdb") dim c as string c = "insert into newtable1 values ('liqiao','20')" mydb.execute c msgbox "成功插入一条记录liqiao 20" end sub |
新闻热点
疑难解答