Dim PathName As String
PathName = App.Path
Dim MyTable As TableDef, MyField As Field
Dim MyDatabase As Database
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral)
Set MyTable = MyDatabase.CreateTableDef("Subclass")
Set MyField = MyTable.CreateField("Name", dbText, 50)
MyTable.Fields.Append MyField
MyDatabase.TableDefs.Append MyTable
Set MyTable = MyDatabase.CreateTableDef("AllRecords")
Set MyField = MyTable.CreateField("Name", dbText, 50)
MyTable.Fields.Append MyField
Set MyField = MyTable.CreateField("Source", dbText, 50)
MyTable.Fields.Append MyField
MyDatabase.TableDefs.Append MyTable
End Sub
这样建立起来的数据库,用ACCESS2000打开,总是提示是旧格式的数据库
高手帮忙```
11 个解决方案
#1
将你代码中的:
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral)
改为
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral,dbVersion40)
就可以了
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral)
改为
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral,dbVersion40)
就可以了
#2
关注!
我先后用DAO和ADO建立的数据库,都遇到像你这样的情况.最后我的解决办法是建立模板文件,在"新建"的菜单命令中打开复制后的模板文件,代替事实上的新建.算是曲线救国.
我先后用DAO和ADO建立的数据库,都遇到像你这样的情况.最后我的解决办法是建立模板文件,在"新建"的菜单命令中打开复制后的模板文件,代替事实上的新建.算是曲线救国.
#3
你引用的DAO版本要用3.6以上的
#4
同意 kill2003 我刚才忘说了
#5
我建议你用ADO
选择JET 4.0 用ADOX的create 创建
选择JET 4.0 用ADOX的create 创建
#6
来晚了不是!!
#7
引用了dao3.6后
Set MyField = MyTable.CreateField("Name", dbText, 50)
这行出错:
类型不匹配
???
Set MyField = MyTable.CreateField("Name", dbText, 50)
这行出错:
类型不匹配
???
#8
引用了DAO3.6 OBJECT LIBRARY
Set MyField = MyTable.CreateField("Name", dbText, 50)
出错:类型不匹配
Set MyField = MyTable.CreateField("Name", dbText, 50)
出错:类型不匹配
#9
'建立MDB数据库
Sub MakeMDB(PathName As String)
Dim strTablename As String
Dim MyTable As TableDef, MyField As Field
Dim MyDatabase As Database
Set MyDatabase = CreateDatabase(PathName + "\Rsgz.mdb", dbLangGeneral)
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
conn.ConnectionString = "DBQ=" & App.Path & "\sys\SYSINFO.mdb;DRIVER={Microsoft Access Driver (*.mdb)};"
conn.Open
sql = "select 表名 from TABLESTRUC group by 表名"
Set rs = conn.Execute(sql)
Do While Not rs.eof
strTablename = rs("表名")
Set MyTable = MyDatabase.CreateTableDef(strTablename)
Dim conn1 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
conn1.ConnectionString = "DBQ=" & App.Path & "\sys\SYSINFO.mdb;DRIVER={Microsoft Access Driver (*.mdb)};"
conn1.Open
sql = "select 字段名称,字段类型,字段长度,小数位数 from TABLESTRUC where 表名='" & strTablename & "' order by id"
Set rs1 = conn1.Execute(sql)
Do While Not rs1.eof
Set MyField = MyTable.CreateField(rs("字段名称"), dbText, 50) '出错:类型不匹配
MyTable.Fields.Append MyField
Set MyField = Nothing
rs1.MoveNext
Loop
rs1.close
Set rs1 = Nothing
conn1.close
Set conn1 = Nothing
MyDatabase.TableDefs.Append MyTable
Set MyTable = Nothing
rs.MoveNext
Loop
rs.close
Set rs = Nothing
conn.close
Set conn = Nothing
Set MyDatabase = Nothing
End Sub
Sub MakeMDB(PathName As String)
Dim strTablename As String
Dim MyTable As TableDef, MyField As Field
Dim MyDatabase As Database
Set MyDatabase = CreateDatabase(PathName + "\Rsgz.mdb", dbLangGeneral)
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
conn.ConnectionString = "DBQ=" & App.Path & "\sys\SYSINFO.mdb;DRIVER={Microsoft Access Driver (*.mdb)};"
conn.Open
sql = "select 表名 from TABLESTRUC group by 表名"
Set rs = conn.Execute(sql)
Do While Not rs.eof
strTablename = rs("表名")
Set MyTable = MyDatabase.CreateTableDef(strTablename)
Dim conn1 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
conn1.ConnectionString = "DBQ=" & App.Path & "\sys\SYSINFO.mdb;DRIVER={Microsoft Access Driver (*.mdb)};"
conn1.Open
sql = "select 字段名称,字段类型,字段长度,小数位数 from TABLESTRUC where 表名='" & strTablename & "' order by id"
Set rs1 = conn1.Execute(sql)
Do While Not rs1.eof
Set MyField = MyTable.CreateField(rs("字段名称"), dbText, 50) '出错:类型不匹配
MyTable.Fields.Append MyField
Set MyField = Nothing
rs1.MoveNext
Loop
rs1.close
Set rs1 = Nothing
conn1.close
Set conn1 = Nothing
MyDatabase.TableDefs.Append MyTable
Set MyTable = Nothing
rs.MoveNext
Loop
rs.close
Set rs = Nothing
conn.close
Set conn = Nothing
Set MyDatabase = Nothing
End Sub
#10
Private Sub Form_Load()
Dim PathName As String
PathName = App.Path
Dim MyTable As TableDef, MyField As Field
Dim MyDatabase As Database
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral)
Set MyTable = MyDatabase.CreateTableDef("Subclass")
Set MyField = MyTable.CreateField("Name", dbText, 50)
MyTable.Fields.Append MyField
MyDatabase.TableDefs.Append MyTable
Set MyTable = MyDatabase.CreateTableDef("AllRecords")
Set MyField = MyTable.CreateField("Name", dbText, 50)
MyTable.Fields.Append MyField
Set MyField = MyTable.CreateField("Source", dbText, 50)
MyTable.Fields.Append MyField
MyDatabase.TableDefs.Append MyTable
End Sub
Dim PathName As String
PathName = App.Path
Dim MyTable As TableDef, MyField As Field
Dim MyDatabase As Database
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral)
Set MyTable = MyDatabase.CreateTableDef("Subclass")
Set MyField = MyTable.CreateField("Name", dbText, 50)
MyTable.Fields.Append MyField
MyDatabase.TableDefs.Append MyTable
Set MyTable = MyDatabase.CreateTableDef("AllRecords")
Set MyField = MyTable.CreateField("Name", dbText, 50)
MyTable.Fields.Append MyField
Set MyField = MyTable.CreateField("Source", dbText, 50)
MyTable.Fields.Append MyField
MyDatabase.TableDefs.Append MyTable
End Sub
#11
如果你引用了DAO3.6,请用下面的代码建Access2000格式的数据库
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral,dbVersion40)
请注意:
Const dbVersion40 = 64 (&H40),代表的是ACCESS2000的格式
DAO.DatabaseTypeEnum 的成员
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral,dbVersion40)
请注意:
Const dbVersion40 = 64 (&H40),代表的是ACCESS2000的格式
DAO.DatabaseTypeEnum 的成员
#1
将你代码中的:
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral)
改为
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral,dbVersion40)
就可以了
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral)
改为
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral,dbVersion40)
就可以了
#2
关注!
我先后用DAO和ADO建立的数据库,都遇到像你这样的情况.最后我的解决办法是建立模板文件,在"新建"的菜单命令中打开复制后的模板文件,代替事实上的新建.算是曲线救国.
我先后用DAO和ADO建立的数据库,都遇到像你这样的情况.最后我的解决办法是建立模板文件,在"新建"的菜单命令中打开复制后的模板文件,代替事实上的新建.算是曲线救国.
#3
你引用的DAO版本要用3.6以上的
#4
同意 kill2003 我刚才忘说了
#5
我建议你用ADO
选择JET 4.0 用ADOX的create 创建
选择JET 4.0 用ADOX的create 创建
#6
来晚了不是!!
#7
引用了dao3.6后
Set MyField = MyTable.CreateField("Name", dbText, 50)
这行出错:
类型不匹配
???
Set MyField = MyTable.CreateField("Name", dbText, 50)
这行出错:
类型不匹配
???
#8
引用了DAO3.6 OBJECT LIBRARY
Set MyField = MyTable.CreateField("Name", dbText, 50)
出错:类型不匹配
Set MyField = MyTable.CreateField("Name", dbText, 50)
出错:类型不匹配
#9
'建立MDB数据库
Sub MakeMDB(PathName As String)
Dim strTablename As String
Dim MyTable As TableDef, MyField As Field
Dim MyDatabase As Database
Set MyDatabase = CreateDatabase(PathName + "\Rsgz.mdb", dbLangGeneral)
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
conn.ConnectionString = "DBQ=" & App.Path & "\sys\SYSINFO.mdb;DRIVER={Microsoft Access Driver (*.mdb)};"
conn.Open
sql = "select 表名 from TABLESTRUC group by 表名"
Set rs = conn.Execute(sql)
Do While Not rs.eof
strTablename = rs("表名")
Set MyTable = MyDatabase.CreateTableDef(strTablename)
Dim conn1 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
conn1.ConnectionString = "DBQ=" & App.Path & "\sys\SYSINFO.mdb;DRIVER={Microsoft Access Driver (*.mdb)};"
conn1.Open
sql = "select 字段名称,字段类型,字段长度,小数位数 from TABLESTRUC where 表名='" & strTablename & "' order by id"
Set rs1 = conn1.Execute(sql)
Do While Not rs1.eof
Set MyField = MyTable.CreateField(rs("字段名称"), dbText, 50) '出错:类型不匹配
MyTable.Fields.Append MyField
Set MyField = Nothing
rs1.MoveNext
Loop
rs1.close
Set rs1 = Nothing
conn1.close
Set conn1 = Nothing
MyDatabase.TableDefs.Append MyTable
Set MyTable = Nothing
rs.MoveNext
Loop
rs.close
Set rs = Nothing
conn.close
Set conn = Nothing
Set MyDatabase = Nothing
End Sub
Sub MakeMDB(PathName As String)
Dim strTablename As String
Dim MyTable As TableDef, MyField As Field
Dim MyDatabase As Database
Set MyDatabase = CreateDatabase(PathName + "\Rsgz.mdb", dbLangGeneral)
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
conn.ConnectionString = "DBQ=" & App.Path & "\sys\SYSINFO.mdb;DRIVER={Microsoft Access Driver (*.mdb)};"
conn.Open
sql = "select 表名 from TABLESTRUC group by 表名"
Set rs = conn.Execute(sql)
Do While Not rs.eof
strTablename = rs("表名")
Set MyTable = MyDatabase.CreateTableDef(strTablename)
Dim conn1 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
conn1.ConnectionString = "DBQ=" & App.Path & "\sys\SYSINFO.mdb;DRIVER={Microsoft Access Driver (*.mdb)};"
conn1.Open
sql = "select 字段名称,字段类型,字段长度,小数位数 from TABLESTRUC where 表名='" & strTablename & "' order by id"
Set rs1 = conn1.Execute(sql)
Do While Not rs1.eof
Set MyField = MyTable.CreateField(rs("字段名称"), dbText, 50) '出错:类型不匹配
MyTable.Fields.Append MyField
Set MyField = Nothing
rs1.MoveNext
Loop
rs1.close
Set rs1 = Nothing
conn1.close
Set conn1 = Nothing
MyDatabase.TableDefs.Append MyTable
Set MyTable = Nothing
rs.MoveNext
Loop
rs.close
Set rs = Nothing
conn.close
Set conn = Nothing
Set MyDatabase = Nothing
End Sub
#10
Private Sub Form_Load()
Dim PathName As String
PathName = App.Path
Dim MyTable As TableDef, MyField As Field
Dim MyDatabase As Database
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral)
Set MyTable = MyDatabase.CreateTableDef("Subclass")
Set MyField = MyTable.CreateField("Name", dbText, 50)
MyTable.Fields.Append MyField
MyDatabase.TableDefs.Append MyTable
Set MyTable = MyDatabase.CreateTableDef("AllRecords")
Set MyField = MyTable.CreateField("Name", dbText, 50)
MyTable.Fields.Append MyField
Set MyField = MyTable.CreateField("Source", dbText, 50)
MyTable.Fields.Append MyField
MyDatabase.TableDefs.Append MyTable
End Sub
Dim PathName As String
PathName = App.Path
Dim MyTable As TableDef, MyField As Field
Dim MyDatabase As Database
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral)
Set MyTable = MyDatabase.CreateTableDef("Subclass")
Set MyField = MyTable.CreateField("Name", dbText, 50)
MyTable.Fields.Append MyField
MyDatabase.TableDefs.Append MyTable
Set MyTable = MyDatabase.CreateTableDef("AllRecords")
Set MyField = MyTable.CreateField("Name", dbText, 50)
MyTable.Fields.Append MyField
Set MyField = MyTable.CreateField("Source", dbText, 50)
MyTable.Fields.Append MyField
MyDatabase.TableDefs.Append MyTable
End Sub
#11
如果你引用了DAO3.6,请用下面的代码建Access2000格式的数据库
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral,dbVersion40)
请注意:
Const dbVersion40 = 64 (&H40),代表的是ACCESS2000的格式
DAO.DatabaseTypeEnum 的成员
Set MyDatabase = CreateDatabase(PathName + "\Favorite.mdb", dbLangGeneral,dbVersion40)
请注意:
Const dbVersion40 = 64 (&H40),代表的是ACCESS2000的格式
DAO.DatabaseTypeEnum 的成员