IIS開啟ASP.net

設置IIS開啟ASP.net時,網頁出現這樣的錯誤,要怎樣解決?

Server Error in '/' Application.

--------------------------------------------------------------------------------

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

2 Answers

Rating
  • 1 decade ago
    Favorite Answer

    我從您這個 NameSpace(System.Data.SqlClient),得知您是連結 MS SQL Server

    您可以檢查一下,您的資料庫連結字串(ConnectionString)寫在哪裡?

    不管是寫死在程式裡面,或是寫在 Web.Config檔案內

    都可以自己修改。

    資料庫連結字串(ConnectionString)不需要死背!不用記憶!

    最簡單的方法,就是透過開發工具(例如 VS 2010 or VS 2008)的 SqlDataSource

    這個精靈會幫您完成,完成後,您把那段資料庫連結字串(ConnectionString)COPY下來即可

    這裡是我寫的文章,您可以參考一下:

    OdbcConnection 與OleDbConnection 的連結資料庫字串 ...http://www.dotblogs.com.tw/mis2000lab/archive/2009...

    [習題]透過SqlDataSource連結Access資料庫- MIS2000 Lab.的ASP.NET專題 ...

    ASP.NET連結SQL Server Express的連接字串(Connection String ...

  • 湯包
    Lv 7
    1 decade ago

    無法連接到 SQL 伺服器....

    請檢查一下 Connection String

    或 SQL 伺服器是否允許連線

Still have questions? Get your answers by asking now.