How Do I Automatically Get Pc Name In Connection String
try this..
or
gives you current pc name..
System.Net.Dns.GetHostName();
or
System.Environment.GetEnvironmentVariable("COMPUTERNAME");
gives you current pc name..
SqlConnectionStringBuilder connectionString = new SqlConnectionStringBuilder();
connectionString.DataSource = System.Net.Dns.GetHostName();
connectionString.InitialCatalog = "MyDatabase";
connectionString.IntegratedSecurity = true;
No comments :
Post a Comment