Reputation: 779
i am creating a setup project for my c# application.
what is need is i want to integrate mssql database (.mdf and .ldf file) with setup.so that database file is copied to
Microsoft SQL Server\MSSQL.1\MSSQL\Data
in program Files and get attached to the sqlexpress data base during installation.
thanks in advance.
Upvotes: 1
Views: 3636
Reputation: 1520
are you looking to deploy this so that it can only be used by a single user or are you looking to deploy so that multiple users can connect to your database?
Does this article offer the information you are looking for? http://msdn.microsoft.com/en-us/library/ms165716(v=sql.90).aspx
In a single user deployment, SQL Server Compact edition is very simple to deploy. There is no ldf or mdf file to worry about. You simply have 1 sdf file which you can just xCopy onto the client system. You can then instantly connect to your database without having to worry about the sql express database engine itself.
If you move your database into sql server compact, you can connect to it on the client using simple code like this.
Example:
public static DbConnection GetConnection() {
string connectString = @"Data Source=" + GetFullPathToDB() + ";Password=YourPassWord;Persist Security Info=False;";
SqlCeConnection cn = new SqlCeConnection(connectString);
return cn;
}
One downside that I will mention about Sql Compact is, at the time of this writing, there is no suport for SMO in C#.
Upvotes: 1
Reputation: 8152
If I'm understanding you correctly, this blog post walks you through deploying SQL Server 2008 Express as a prerequisite, and this MSDN article explains how to deploy your MDF using Xcopy.
As an alternative, you could look at using SQL Server Compact Edition, as there is no installation needed to run, it's free and lightweight, and easy to deploy (just a file copy).
Upvotes: 2