在vb中動(dòng)態(tài)創(chuàng)建數(shù)據(jù)庫
新建工程.添加控件 對(duì)應(yīng)寫上代碼
| 以下為引用的內(nèi)容: 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 "成功創(chuàng)建mydb3.mdb數(shù)據(jù)庫外加一條記錄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 |
新聞熱點(diǎn)
疑難解答
圖片精選