当前位置:编程学习 > VB >>

用代码创建数据库,表,字段

 

 

Option Explicit

Private db As Database

Private td As TableDef

Private f As Field

 

Private Sub Command1_Click()

Set db = DBEngine.CreateDatabase("d:1.mdb", dbLangGeneral)

Set td = New TableDef

 

Set f = td.CreateField("NAME", dbText, 20)

td.Fields.Append f

 

Set f = td.CreateField("ID", dbText, 5)

td.Fields.Append f

 

Set f = td.CreateField("DEPARTMENTP", dbText, 60)

td.Fields.Append f

 

 

td.Name = "class"

db.TableDefs.Append td

 

Set db = Nothing

 

End Sub

 

在列表框中显示该字段名

你可以设一个变量,取得"该字段名",再添加到列表框中(加上循环),列表框的操作你可以看VB的帮助

 

补充:软件开发 , Vb ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,