我正在使用Web部件創建儀表板頁面。要做到這一點,我動態加載webparts。由Web部件導致的SQL Server錯誤
strZoneNumber = "zone" + intCnt.ToString();
UserControl UC = (UserControl)LoadControl(row["c_widget_path"].ToString());//Loads the usercontrol
UC.ID = row["c_widget_webid"].ToString();
UC.Attributes.Add("Title", row["c_widget_webid"].ToString());
//UC.Attributes.Add("title" , "Test");
GenericWebPart ucwebPart = wpmDashBoardManager.CreateWebPart(UC);//creates a webpart
wpmDashBoardManager.AddWebPart(ucwebPart, wpmDashBoardManager.Zones[strZoneNumber], ZoneIndex);//adds it to a zone
wpmDashBoardManager.Zones[strZoneNumber].Visible = true;
我WebPartManager的個性化模式設置爲「真」
雖然它給我下面的錯誤在服務器上運行此頁:
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.
SQLExpress database file auto-creation error: The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:
如果應用程序App_Data目錄不已存在,則Web服務器帳戶必須具有對應用程序目錄的讀取和寫入權限。這是必要的,因爲如果Web服務器帳戶尚不存在,它將自動創建App_Data目錄。
如果應用程序App_Data目錄已經存在,則Web服務器帳戶只需要對應用程序App_Data目錄進行讀寫訪問。這是必要的,因爲Web服務器帳戶將嘗試驗證Sql Server Express數據庫已經存在於應用程序的App_Data目錄中。從Web服務器帳戶撤銷對App_Data目錄的讀取訪問將阻止提供者正確確定Sql Server Express數據庫是否已存在。當提供者試圖創建已經存在的數據庫的副本時,這將導致錯誤。寫訪問權限是必需的,因爲在創建新數據庫時使用了Web服務器帳戶憑證。
Sql Server Express必須安裝在機器上。 Web服務器帳戶的進程標識必須具有本地用戶配置文件。有關如何爲機器和域帳戶創建本地用戶配置文件的詳細信息,請參閱自述文檔。**
有關可能導致此問題和解決方案的任何想法?幫助將不勝感激:) :)