- 127.0.0.1
- localhost
- . (dot means localhost)
All fine for connecting to local database.
Вопрос
I am running sql server 2012 on a server and I had my website running on another server. I always used a connection string like this to connect to the server:
connectionString="Data Source = xxx.xxx.xxx.xxx; Initial Catalog=MyDatabase; Integrated Security=false; User ID=MyUserName; Password=MyPassword"
but now when I moved the website to the same computer as the database, I wasn't sure what my connection string should look like so I just changed Data Source = "127.0.0.1"
and used the localhost ip to connect to it. It works fine, but is there a better or more appropriate way to do it?
Thanks
Решение
All fine for connecting to local database.
Другие советы
connectionString="Data Source =.; Initial Catalog=MyDatabase; Integrated Security=false; User ID=MyUserName; Password=MyPassword"
if you use "." as your data source it means local machine