2012-09-21 52 views
0

請我已經看到了這個錯誤:連接名稱「SQL」在應用程序的配置沒有被發現或者連接字符串爲空

The connection name 'SQL' was not found in the applications configuration or the connection string is empty. 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.

我知道一個事實,即連接名稱「SQL」的存在和它可以在我的本地機器上正常工作。

我開始看到這個錯誤後,我在我的部署服務器上解決了這個問題其他錯誤:所建議here

請我將不勝感激任何幫助設置訪問權限

Compiler Error Message: BC31007: Unable to open module file 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files

謝謝!

部署環境:Windows Server 2003中,.NET 4.0
開發環境:寡婦7,.NET 4.0

請注意:部署的應用一直非常清楚在現場,超過3個月,到最後星期五晚上。

客戶端在服務器或其環境中未發生任何變化。

我的Web配置:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <appSettings> 
     <add key="LoginMode" value="2" /> 
     <add key="CustomeModules" value="True" /> 
     <add key="TopCallersRefeshInterval" value="600" /> 
     <add key="OperatorAccountName" value="" /> 
     <add key="ChartImageHandler" value="storage=file;timeout=20;dir=C:\TempImageFiles\;"/> 
    </appSettings> 
    <connectionStrings> 
     <add name="SQL" connectionString="server=.\SQL2008;database=xxxxxx;uid=xxxxxx;pwd=xxxxxxxxxx;" providerName="System.Data.SqlClient" /> 
     <add name="SQLCustom" connectionString="server=.\SQL2008;database=xxxxxx;uid=xxxxxx;pwd=xxxxxxxxxx;" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <system.web> 
     <httpHandlers> 
    <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" /> 
    </httpHandlers> 
    <pages> 
    <controls> 
     <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
    </controls> 
    </pages> 
    <compilation debug="true" targetFramework="4.0" explicit="true"> 
      <assemblies> 
       <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /> 
       <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
       <add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
       <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
       <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /></assemblies> 
     </compilation> 
    </system.web> 
    <system.webServer> 
     <defaultDocument> 
      <files> 
           <remove value="login.aspx" /> 
       <remove value="iisstart.htm" /> 
       <remove value="default.aspx" /> 
       <remove value="index.html" /> 
       <remove value="index.htm" /> 
       <remove value="Default.asp" /> 
       <remove value="Default.htm" /> 
       <add value="home.aspx" /> 
      </files> 
     </defaultDocument> 
     <handlers> 
      <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
     </handlers> 
    </system.webServer> 
</configuration> 
+0

你可以發佈你的web.config請。 –

+0

@Jon Egerton,我已經添加了web.config –

+0

和部署服務器的web.config的相關部分? – gerd

回答

1

但是,你試圖連接到遠程數據庫(即部署服務器上的數據庫)或本地數據庫。

也許有人已經觸及訪問權限的數據庫...

順便說一句,你怎麼修正原來的錯誤?

+0

這是一個本地數據庫。一個本地數據庫。我通過授予訪問一些系統帳戶的權限來解決初始錯誤http://falhan.net/?p=152 –

+0

我也在使用MS SQL Server 2008,我沒有使用'ProviderName''系統。 Data.SqlClient',而是連接字符串中的'System.Data.EntityClient'。你可以試試這個改變嗎?也許你必須在項目中添加引用。 – adripanico

+0

也有可能您的本地數據庫使用Windows身份驗證,而不是自己的身份驗證,而遠程數據庫則相反。以防萬一,我的完整ConnectionString是' ([更多信息](http://connectionstrings.com/sql-server-2008)) – adripanico

0

刪除所有文件(S)與格式的.config即 「web.user.config」,而是 「web.config中」。

我希望它幫助:)

+0

我只部署web.config,沒有其他配置在網站上使用 –

-1

嘗試在web.config中

connectionStrings> 
    <clear /> 
    <add name="SQL" connectionString="server=.\SQL2008;database=xxxxxx;uid=xxxxxx;pwd=xxxxxxxxxx;" providerName="System.Data.SqlClient" /> 
     ..... 
</connectionStrings> 
+0

將在星期一嘗試它......但我有我的疑惑。爲什麼一個突然工作得很好的系統只是先用ASP.net編譯錯誤來開發問題,然後再用connectionString呢? –

0

加入您的連接字符串下</clear>清除出你的服務器上的臨時文件夾。重新編譯,重新部署並查看是否可以爲您解決問題。另外:

<connectionStrings> 
    <clear /> 
    <remove name="SQL"/> 
    <add name="SQL" 
     connectionString="server=.\SQL2008;database=xxxxxx;uid=xxxxxx;pwd=xxxxxxxxxx;" 
      providerName="System.Data.SqlClient" /> 
     ..... 
</connectionStrings> 

如果還是不行,請嘗試使用遠程調試會話:

How to: Set Up Remote Debugging

+1

+1它們位於:C:\ WINDOWS \ Microsoft.NET \ Framework \ <.Net版本> \ Temporary ASP.NET Files – 5arx

+0

謝謝5arx :-) – IrishChieftain

+0

也試過這個,但沒有運氣 –

相關問題