문제

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

도움이 되었습니까?

해결책

  • 127.0.0.1
  • localhost
  • . (dot means localhost)

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top