Last post Feb 16, 2015 08:12 AM by Michelle Ge - MSFT
Feb 13, 2015 02:28 AM|Amirg|LINK
I am gonna configure connection string and I wonder if anyone can tell me how to read server name? Should I read server name or instead i can simply use "localhost" . below is an example
connectionString="Data Source=localhost ;Initial Catalog=my database name;Integrated Security=False; User ID = xxx; Password=xxx"
can you give me any code for obtaining server name and use in the "Data Source" field?
Feb 13, 2015 02:40 AM|Mikesdotnetting|LINK
If the SQL Server instance is a default instance, you can use "localhost" or just .\ It is is a named instance you will have to add that after the backslash:
You need to ask the administrator of the server for these details.
Feb 13, 2015 04:01 AM|Amirg|LINK
well, I asked the admin and he says that I should use localhost. So which one of these configurations should be used?
Data Source=localhost\My_database_name ???
Feb 13, 2015 05:28 AM|Mikesdotnetting|LINK
Data Source = Localhost.
You provide your database name to the Initial Catalog property.
Feb 16, 2015 08:12 AM|Michelle Ge - MSFT|LINK
So far as I know, you can set your server name in the server property, and set the DataBase file path in the DataBase property.
For more information, please refer to the code below:
Hope it's useful for you.