2017-05-26 403 views
0

我已經爲mySQL完成了此應用程序,但現在我必須將它重新制作爲oracle。所以現在我遇到了這個未找到網絡路徑C#和Oracle

Server Error in '/' Application.

The network path was not found

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.ComponentModel.Win32Exception: The network path was not found

Source Error:

Line 222: //By department result. Line 223:
GridDatasource1(); Line 224: GridView1.DataBind(); Line 225: //End of by department result. Line 226:
//Multiple surname results.

Source File: C:\Users\tomas.filip\Documents\Visual Studio 2015\Projects\WebApplication1\WebApplication1\Default.aspx.cs Line: 224

Stack Trace:

[Win32Exception (0x80004005): The network path was not found]

[SqlException (0x80131904): 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) +1418
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +470
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +70
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +945
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +114
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1637
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +117
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +267
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource 1 retry, DbConnectionOptions userOptions) +318
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource
1 retry) +132
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +246 System.Data.SqlClient.SqlConnection.Open() +122
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +177
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +182
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +123
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +2964
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +26
WebApplication1._Default.Button1_Click(Object sender, EventArgs e) in C:\Users\tomas.filip\Documents\Visual Studio 2015\Projects\WebApplication1\WebApplication1\Default.aspx.cs:224
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +11828965
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +150 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1735

這裏有代碼的領域。

//By department result. 
GridDatasource1(); 
GridView1.DataBind(); 
//End of by department result. 

功能

protected void GridDatasource1() 
     { 
      SqlDataSource SqlDataSource2 = new SqlDataSource(); 
      SqlDataSource2.ID = "SqlDataSource2"; 
      this.Page.Controls.Add(SqlDataSource2); 
      SqlDataSource2.ConnectionString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString; 
      SqlDataSource2.SelectCommand = "SELECT * FROM v_employees_intr where PLACE like '" + DropDownList1.SelectedValue + "' ORDER BY '" + RadioButtonList1.SelectedValue + "' ASC;"; 
      GridView1.DataSource = SqlDataSource2;   
     } 

而且conString

<add name="conString" connectionString="DATA SOURCE=epcepc091:1521/XE;PERSIST SECURITY INFO=True;USER ID=SYSTEM;Password=Epce12345" providerName="System.Data.OracleClient" /> 

我試圖找到解決辦法,但unsuccesfuly。任何幫助我都會很樂意。謝謝。

+0

這似乎是錯誤的:_DATA SOURCE = epcepc091:1521/XE_你應該把端口號作爲最後一部分_epcepc091/XE:1521_ – Steve

+0

好吧,那不是它:/ –

+0

異常指向一個SqlConnection的失敗,但這不應將ProviderName設置爲Oracle庫。這就像提供者名稱是錯誤的。你可以嘗試直接在代碼中設置ProviderName屬性,而不是通過ConnectionString隱式設置? – Steve

回答

1

所以拜塞弗,感謝你真的 所有我需要做的就是添加

SqlDataSource2.ProviderName = "System.Data.OracleClient"; 

不知道爲什麼它不是Web.config中工作。謝謝史蒂夫。

相關問題