找不到网络路径C#和Oracle

时间:2017-05-26 07:14:33

标签: c# oracle visual-studio-2015

我已经为mySQL完成了这个应用程序,但现在我必须为oracle重新制作它。所以现在我遇到了这个

  

' /'中的服务器错误应用

     

找不到网络路径

     

描述:执行期间发生了未处理的异常   当前的网络请求。请查看堆栈跟踪了解更多信息   有关错误的信息以及它在代码中的起源。

     

异常详细信息:System.ComponentModel.Win32Exception:网络   找不到路径

     

来源错误:

     

第222行://按部门结果。第223行:
  GridDatasource1();第224行:GridView1.DataBind();线   225://按部门结果结束。第226行:
  //多个姓氏结果。

     

源文件:C:\ Users \ tomas.filip \ Documents \ Visual Studio   2015 \ Projects \ WebApplication1 \ WebApplication1 \ Default.aspx.cs行:   224

     

堆栈追踪:

     

[Win32Exception(0x80004005):找不到网络路径]

     

[SqlException(0x80131904):与网络相关或特定于实例的   建立与SQL Server的连接时发生错误。该   服务器未找到或无法访问。验证该实例   名称是正确的,并且SQL Server配置为允许远程   连接。 (提供者:命名管道提供者,错误:40 - 不能   打开与SQL Server的连接)]
  System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity   identity,SqlConnectionString connectionOptions,SqlCredential   凭证,Object providerInfo,String newPassword,SecureString   newSecurePassword,Boolean redirectedUserInstance,SqlConnectionString   userConnectionOptions,SessionData reconnectSessionData,   DbConnectionPool池,String accessToken,Boolean   applyTransientFaultHandling)+1418
  System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions   options,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo,   DbConnectionPool池,DbConnection owningConnection,   DbConnectionOptions userOptions)+470
  System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(类DBConnectionPool   pool,DbConnection owningObject,DbConnectionOptions选项,   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&连接)+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重试,DbConnectionOptions   userOptions,DbConnectionInternal oldConnection,DbConnectionInternal&   连接)+267
  System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(的DbConnection   outerConnection,DbConnectionFactory connectionFactory,   TaskCompletionSource 1 retry, DbConnectionOptions userOptions) +318
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource
1   重试)+132
  System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1   重试)+246 System.Data.SqlClient.SqlConnection.Open()+122
  System.Data.Common.DbDataAdapter.FillInternal(DataSet数据集,   DataTable [] datatables,Int32 startRecord,Int32 maxRecords,String   srcTable,IDbCommand命令,CommandBehavior行为)+177
  System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,Int32   startRecord,Int32 maxRecords,String srcTable,IDbCommand命令,   CommandBehavior行为)+182
  System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,String   srcTable)+123
  System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments   参数)+2964
  System.Web.UI.DataSourceView.Select(DataSourceSelectArguments   参数,DataSourceViewSelectCallback回调)+26
  WebApplication1._Default.Button1_Click(Object sender,EventArgs e)in   C:\ Users \ tomas.filip \ Documents \ Visual Studio   2015 \项目\ WebApplication1 \ WebApplication1 \ Default.aspx.cs:224
  System.Web.UI.WebControls.Button.OnClick(EventArgs e)+11828965
  System.Web.UI.WebControls.Button.RaisePostBackEvent(字符串   eventArgument)+150 System.Web.UI.Page.ProcessRequestMain(布尔值   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" />

我试图找到解决方案,但不成功。我会很乐意为你提供任何帮助。谢谢。

1 个答案:

答案 0 :(得分:1)

非常感谢Seve,非常感谢你 我所要做的就是添加

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

不知道为什么它在Web.config中不起作用。谢谢史蒂夫。