开发者

How to include .sdf database file when packaging my application

I was able to create an application in VB.net that talks to a SQL Server CE database.

Now i want to deploy this application using the publish feature with clickonce.

An issue im ha开发者_运维知识库ving tho is when I install the application on another computer it keeps looking for my sql server on my development pc.

Ive added the .sdf when i package my solution but its still an issue.

How do I change my connection string to connect to the .sdf file that I included in the package?

this is my current connection string which looks at the sql server: connectionString = " Data Source=CHRIS-PC\SQLEXPRESS;Initial Catalog=ce_db;Integrated Security=True"

Thanks !!


connectionString = "Data Source=localhost\SQLEXPRESS;Initial Catalog=ce_db;Integrated Security=True"

or perhaps

connectionString = "Data Source=" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\ce_db.sdf;Persist Security Info=False;";

this connection string would work if you had the database in the same directory as the executable using it.

essencially the data source is either the database server that you are connecting to, or the database file that you are connecting to.

If you are using a file then you have only one catalog. and if you are using a server then you will want to specify a specific catalog using the Initial catalog attribute of the connection string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜