Reputation: 989
i am new to program,and our teacher asked us to write a small program witch using sqlserver; so i use visual studio 2010 c# to write it,but i meet a problem: i don't know how to make a setup file.because i put the SqlConnectionString in the code file directly;so,even i have publish the program ,the sqlconnectionstring didn't change,it didn't works~ this is the first time to write this kind program,and i dont know how to make it work right on others computer; can you tell me the way to solve it? do i need change the way of coding?how? thanks~
Upvotes: 0
Views: 85
Reputation: 55059
Put the connection string in the config file, that way it can be updated without needing a recompile. The easiest way to do that is to open the Properties
folder in the Solution Explorer
and then doubleclick on the Settings.settings
file, then you get a easy to use interface to create a config file value that you can later reference in your code without needing to write any code for reading the config file.
Upvotes: 2