Reputation: 263
Can anyone tell me the accurate way of deployment my C# application with a SQL Server database? I want to run my application on client's machine, it is running on my machine but showing error on client's machine. I have already installed SQL Server 2012 on client's machine. I know little about deployment as I am doing it for the first time. I know there is a need to attach .mdf
file first. Please tell me the exact steps of deployment so that I am able to run my application on client's machine. The thing I need to mention is that the application is simple windows based application!
Upvotes: 2
Views: 9144
Reputation: 3360
.mdf
file and select it. .mdf
file
you just added to your Project.
You can now use this connection string in your code like this:
Properties.Settings.Default.ConString;
This connection string will be like:
“Data Source=GAMING;AttachDbFilename=|DataDirectory|\management_system.mdf;Integrated Security=True”
So when you produce the .exe
file or setup file of your application your database file will be packaged with it and stored in the |DataDirectory| on your client PC and the connection string will access your database file just like that and your application will work on any PC given that SQL server is installed. I have not found a way to not to install SQL server on client PC and still run the application. If I do find it in the future, I will post it here :P
Upvotes: 2
Reputation: 799
You can probably look at the account used in the connection string.
I suspect that you were using a windows account to access the database on your computer while you haven't added a windows account to the SQL server on the client's computer.
So if you use an SQL user to login to the SQL studio management, you can use this login in your connection string. Or just simply add a default windows account login to SQL.
Upvotes: 0
Reputation: 2917
1 - Attach database to the SQL Server instance (Either using .mdf and .ldf files or using a DB backup)
2 - Change your connection string before deploying the application in client machine. If you don't have a config file and you've hard coded the connection string then you'll have to change the connection string to reflect client's machine name, SQL Instance name and DB name and compile the application before deploying.
You may refer to the following URL to get an idea how to configure your connection string.
http://www.connectionstrings.com/sql-server/
Upvotes: 1