如何在vb.net中创建设置? [英] How to create a setup in vb.net?
本文介绍了如何在vb.net中创建设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=C:\solutionvs10\test\test\bin\Debug\db2.mdb;Jet OLEDB:Database Password=secret")
cn.Open()
// codes
cn.Close()
我使用了 VS 2010
上面是我的代码-可以看到它是Ms Access数据库.
如何创建可以容易在其他计算机上安装的设置?
I used VS 2010
Above is my code - one can see that it is Ms Access DataBase.
How can I create a setup that can beeasy to install on other computer?
推荐答案
确切的问题是什么?
是连接字符串,还是正在创建安装程序?
如果要创建安装程序,请查看InnoSetup,它是一个很酷的工具,功能强大且免费.
如果您的问题与连接字符串有关,那么如果数据库存储在program文件夹中,则可以执行以下操作:
What is the problem exactly?
is it the connection string, or a creating a setup program?
if you want to create a setup program have a look at InnoSetup, it''s a cool tool, powerful and free.
If your problem is about the connection string, if your database is stored in the program folder you could do something like that:
<br />
Imports System.Reflection<br />
<br />
Dim path as String = System.Reflection.Assembly.GetExecutingAssembly.Location<br />
<br />
Dim connectionString as String = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + path + "db2.mdb;Jet OLEDB:Database Password=secret"<br />
<br />
cn = New OleDbConnection(connectionString)<br />
cn.Open()<br />
// codes<br />
cn.Close()<br />
如果您的数据库存储在其他位置,则可以将路径存储在注册表或xml文件或ini文件等中...
If your database is store somewhere else you could store the path in the registry or an xml file or an ini file etc...
这篇关于如何在vb.net中创建设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文