Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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 am able to install SQL Server 2008 on client's machine using clickonce technique. Everything is fine until I try to access database in my application. I know little about deployment as I am doing it for the first time. I know there is a need to attach .mdf file . Please tell me the exact steps of deployment so that I am able to run my application on client's machine.How should I deploy database on client machine ??.Can I change installation path on client machine?? By default it gets installed on C:/Users/Admin/Appdata/Roaming/....... path

What I have tried:

I have created a setup file with database included in it.When I deploy my application on client machine it is unable to access the database throwing error
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections"
What connection string should I write to access the database on client machine ??Or you can navigate me to step by step process of windows deployment
Posted
Updated 3-Nov-16 2:32am
v2
Comments
[no name] 3-Nov-16 8:07am    
You need to change your connection string. And make sure that the SQL server is running on the users machine and setup correctly.
Roy1209 3-Nov-16 8:27am    
How do I change connection string or what should I exactly write in the specific connection string ??
[no name] 3-Nov-16 8:38am    
Well I use a text editor to edit my connection strings. Of course you could go the unusual route and ask your user. They are the ones that know how their server is setup.
Roy1209 3-Nov-16 9:05am    
How can I ask the end user to edit the connection string. I just want to create a exe file which on click will install the application along with the database on client machine
[no name] 3-Nov-16 9:11am    
Think about it. How to you get ANY information from your user? You pop up a dialog and have them type in the information. You are making this way more complicated than it needs to be or actually is.

1 solution

0) Are you installing Sql Server 2008, or Sql Server Express 2008?

1) Are you using the actual Microsoft installer to install SQL Server?

2) Installing SQL Server is much more involved than installing SQL Server Express.

3) You have to modify your code (in your application) so that it can detect the installed SQL Server instance, and set the connection string accordingly.

4) Your code should probably NOT just copy the MDF file because the client may already have SQL Server installed, and it my be incompatible with your MDF file. Instead, you should use a series of queries to import your schema, as well as any data that might be supplied with your application.
 
Share this answer
 
Comments
Roy1209 3-Nov-16 9:02am    
0) I am installing SQL Server 2008 R2 Express
1) Yes I am installing with the help of clickonce prerequisite technique
2) much more involved ??
3) Can you provide me certain idea about how can it be done . Do I have to write the code specifically to set connection string of client
4) How should I do that ?? Should I create a database queries and than run it on client machine.. How to insert database queries while creating .exe file

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900