How to make the sqlconnection string works on all pc's ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to make the sqlconnection string works on all pc's ?

i developped a desktop app that works with sql server database (databas in the same pc) now my problem is that when i deploy my winform app . and want to install it in another computer . i mut know the name of sql server instance + i need to install the database . so how to chexk the name of instance and create the database in it automatically ? thank you guys .

11th May 2017, 7:47 PM
zakaria kasmi
zakaria kasmi - avatar
1 Answer
+ 2
Some of these tasks are better suited to other tools, but I think the easiest solution is to have a file with the information about the sql server that you can edit as needed and read in at run time. You could extend this to having the file save whether you've already created the database, so you know whether you need to run your set up code or not. Alternately you could just assume it's there, and use error handling to rectify the situation. After that, you'd need to make sure that you have all the permissions you'd need on the new computer.
12th May 2017, 12:45 AM
Jim
Jim - avatar