vb 用SQL创建ACCESS多表语句
请问我想用SQL创建另一张表格,应该如何编写.谢谢!!DimDefDatabaseAsDatabaseDimPathNameAsStringDimconnDimsqlAs...
请问我想用SQL创建另一张表格,应该如何编写.谢谢!!
Dim DefDatabase As Database
Dim PathName As String
Dim conn
Dim sql As String
PathName = App.Path
Set DefDatabase = CreateDatabase(PathName + "\db.mdb", dbLangGeneral)
DefDatabase.Close
Set conn = CreateObject("ADODB.Connection")
conn.Open "provider=microsoft.jet.oledb.4.0;data source=" & PathName + "\db.mdb"
sql = "create table MyTable ( 编号 autoincrement(1,1) , 姓名 varchar(50) , constraint pk_test_id primary key(编号))"
'这里想创建另一张新表,应该如何写
.......
.......
conn.Execute sql
MsgBox "创表成功" 展开
Dim DefDatabase As Database
Dim PathName As String
Dim conn
Dim sql As String
PathName = App.Path
Set DefDatabase = CreateDatabase(PathName + "\db.mdb", dbLangGeneral)
DefDatabase.Close
Set conn = CreateObject("ADODB.Connection")
conn.Open "provider=microsoft.jet.oledb.4.0;data source=" & PathName + "\db.mdb"
sql = "create table MyTable ( 编号 autoincrement(1,1) , 姓名 varchar(50) , constraint pk_test_id primary key(编号))"
'这里想创建另一张新表,应该如何写
.......
.......
conn.Execute sql
MsgBox "创表成功" 展开
1个回答
展开全部
Dim DefDatabase As Database
Dim PathName As String
Dim conn
Dim sql As String
PathName = App.Path
Set DefDatabase = CreateDatabase(PathName + "\db.mdb", dbLangGeneral)
DefDatabase.Close
Set conn = CreateObject("ADODB.Connection")
conn.Open "provider=microsoft.jet.oledb.4.0;data source=" & PathName + "\db.mdb"
sql = "create table MyTable ( 编号 autoincrement(1,1) , 姓名 varchar(50) , constraint pk_test_id primary key(编号))"
conn.Execute sql
'-------重复以下这里就可以了
sql = "create table MyTable2 ( 编号 autoincrement(1,1) , 姓名 varchar(50) , constraint pk_test_id primary key(编号))"
conn.Execute sql
'-------重复以上代码
MsgBox "创表成功"
Dim PathName As String
Dim conn
Dim sql As String
PathName = App.Path
Set DefDatabase = CreateDatabase(PathName + "\db.mdb", dbLangGeneral)
DefDatabase.Close
Set conn = CreateObject("ADODB.Connection")
conn.Open "provider=microsoft.jet.oledb.4.0;data source=" & PathName + "\db.mdb"
sql = "create table MyTable ( 编号 autoincrement(1,1) , 姓名 varchar(50) , constraint pk_test_id primary key(编号))"
conn.Execute sql
'-------重复以下这里就可以了
sql = "create table MyTable2 ( 编号 autoincrement(1,1) , 姓名 varchar(50) , constraint pk_test_id primary key(编号))"
conn.Execute sql
'-------重复以上代码
MsgBox "创表成功"
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询