本文介绍了错误:Option Strict on不允许在行"cat.activeconnection close()"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Public Sub expass()
If FileIO.FileSystem.FileExists("c:\security.sys") Then
FileIO.FileSystem.DeleteFile("c:\security.sys")
Dim databaseName As String = "c:\security.mdb"
Dim tableName As String = "KEYS"
Dim cat As ADOX.Catalog = New ADOX.Catalog()
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & databaseName & ";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Password=123;")
cat.ActiveConnection.Close()
cat = Nothing
Dim con As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=ad1e2e$pba#k2;Data Source =" & databaseName)
con.Open()
Dim cmd As New OleDb.OleDbCommand("CREATE TABLE [" + tableName + "] ([Key] TEXT(10))", con)
cmd.ExecuteNonQuery()
cmd = Nothing
MessageBox.Show("Exported Successfully")
con.Close()
con.Dispose()
con = Nothing
FileIO.FileSystem.RenameFile("c:\security.mdb", "security.sys")
Else
Dim databaseName As String = "c:\security.mdb"
Dim tableName As String = "KEYS"
Dim cat As ADOX.Catalog = New ADOX.Catalog()
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & databaseName & ";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Password=123;")
cat.ActiveConnection.Close()
cat = Nothing
Dim con As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=ad1e2e$pba#k2;Data Source =" & databaseName)
con.Open()
Dim cmd As New OleDb.OleDbCommand("CREATE TABLE [" + tableName + "] ([Key] TEXT(10))", con)
cmd.ExecuteNonQuery()
cmd = Nothing
MessageBox.Show("Exported Successfully")
con.Close()
con.Dispose()
con = Nothing
FileIO.FileSystem.RenameFile("c:\security.mdb", "security.sys")
End If
End Sub
推荐答案
这篇关于错误:Option Strict on不允许在行"cat.activeconnection close()"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!