MDB中不需要的ldb文件 [英] Unwanted ldb file in MDB
本文介绍了MDB中不需要的ldb文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请参阅下面的代码..
Hi,
Please see my code below..
string DSource = Path.Combine(CommonItems.DatabaseLocation, lb_project.SelectedItem.ToString() + ".mdb");
string Connection_String = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=1234;" + "Data Source=" + DSource + ";";
ADOX._Catalog cat = new ADOX.Catalog();
cat.Create(Connection_String);
Catalog catalog = new Catalog();
Connection connection = new Connection();
connection.Open(Connection_String, null, null, 0);
catalog.ActiveConnection = connection;
Table seq_table = new Table();
seq_table.Name = "seq_data";
catalog.Tables.Append(seq_table);
seq_table.Columns.Append("seq", ADOX.DataTypeEnum.adVarWChar, 20);
seq_table.Columns.Append("rev", ADOX.DataTypeEnum.adVarWChar, 100);
connection.Close();
创建数据库后我关闭连接,即使ldb文件仍然存在,直到我退出应用程序。
我的代码有什么问题?。我知道ldb不是危险的,但我需要避免不必要的连接。请帮我这个..
After creating the database I am closing the connection, even though the ldb file is still existing until I exit the application.
what is the wrong with my code?.I know ldb is not a dangerous one, but I need to avoid unnecessary connections. Please help me on this..
推荐答案
你实际上打开连接两次,但关闭一次 - 第二次只有在你的应用程序退出后才会关闭...
首先:
You are actually open the connection twice ,but closing once - the second one will be closed only after your application exits...
First:
cat.Create(Connection_String);
第二名:
Second:
connection.Open(Connection_String, null, null, 0);
查看代码,第一个可以删除,你仍然可以得到同样......
Looking at your code, the first can be removed and you still get the same...
这篇关于MDB中不需要的ldb文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文