change data source dynamically from .net application & pass to connectiong string
My Visual Studio .NET application uses SQL Server 2005 Express.
It has to be installed on my customer's main server system & on two client computers.all with Windows XP or Vista or 7.
Now, every time when i install my application & SQL Server on my customers computers, I have to change the server name specified in the connection string, i.e. the DATA SOURCE. Because, when I install SQL Server on customer's computer, then the server name is taken by SQL Server 2005 Express, as the computer name of the customer.
So, what's the solution for this?
- Shall I change the computer name of the customer, to what i have specified in my connection string.
- or , should i take the server name dynamically on runtime from the .net application and then pass it to the connection string.
Also, the same problem is for login? My .NET application would ask for the login & password from the customer, which would then be passed to the connection string & the application would connect to SQL Server. S开发者_如何学Goo, is this ok with security? if not, then what's the other solution to create logins of SQL Server from the .NET application dynamically.
Also, should i create APPLICATION ROLES for this purpose , i.e. for solving the login problem?
My connection string is : Data Source = A-9 (computer name) ; Trusted_Connection = true;
If you are always using a SQL Server Express on the local machine, then the connection string can be changed to .\SQLEXPRESS.
As for the users, you could use windows authentication to get rid of specific usernames/passwords.
精彩评论