对了,那是我调试时忘了改回来
应为:Public Function CreateUserTable(ByVal UserTblName As String, ByVal FileName As String, ByVal DatabasePassword As String) As Boolean
Dim cat As New ADOX.Catalog
Dim tabCreate As ADOX.Table
Dim idxCreate As ADOX.Index
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset'Debug.Print MyStr$conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FileName & ";Jet OLEDB:Database Password=000"
Set cmd.ActiveConnection = conn
rs.CursorLocation = adUseClient
Set tabCreate = New ADOX.Table
tabCreate.Name = txtTable.text
With tabCreate.Columns
.Append "ID", , 20
.Append "Name", , 80
.Append "Password", , 100
.Append "email", , 120
tabCreate.Columns("email").Attributes = adColNullable
End With'****************************************************************
'此处高亮
'错误提示为:
' 实时错误'3420'
' 对象不再有效cat.Tables.Append tabCreate '此处过不了呀
'****************************************************************Set tabCreate = Nothing
With cat.Tables(UserTblName)
Set idxCreate = New ADOX.Index
idxCreate.Name = "ID索引"
idxCreate.Columns.Append "ID"
idxCreate.PrimaryKey = True
idxCreate.Unique = True
.Indexes.Append idxCreate
End With
CreateUserTable = True
Set cat = NothingEnd Function
应为:Public Function CreateUserTable(ByVal UserTblName As String, ByVal FileName As String, ByVal DatabasePassword As String) As Boolean
Dim cat As New ADOX.Catalog
Dim tabCreate As ADOX.Table
Dim idxCreate As ADOX.Index
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset'Debug.Print MyStr$conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FileName & ";Jet OLEDB:Database Password=000"
Set cmd.ActiveConnection = conn
rs.CursorLocation = adUseClient
Set tabCreate = New ADOX.Table
tabCreate.Name = txtTable.text
With tabCreate.Columns
.Append "ID", , 20
.Append "Name", , 80
.Append "Password", , 100
.Append "email", , 120
tabCreate.Columns("email").Attributes = adColNullable
End With'****************************************************************
'此处高亮
'错误提示为:
' 实时错误'3420'
' 对象不再有效cat.Tables.Append tabCreate '此处过不了呀
'****************************************************************Set tabCreate = Nothing
With cat.Tables(UserTblName)
Set idxCreate = New ADOX.Index
idxCreate.Name = "ID索引"
idxCreate.Columns.Append "ID"
idxCreate.PrimaryKey = True
idxCreate.Unique = True
.Indexes.Append idxCreate
End With
CreateUserTable = True
Set cat = NothingEnd Function
'****************************************************************
'此处高亮
'错误提示为:
' 实时错误'3420'
' 对象不再有效cat.Tables.Append tabCreate '此处过不了呀
'****************************************************************