3

Help please with my problem. I get an error when data from Oracle DB "drawing" on web page via asp:SqlDataSource and asp:ListView.

I'm using ODP.Net driver and it works fine (I have many SELECT and UPDATE queries\commands in code-behind and they are working!). But when page must be rendered it says: "The network path was not found "

Exception Details: System.ComponentModel.Win32Exception: The network path was not found

[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.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5341687
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +546
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5353471
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +145
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +923
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +311
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) +646
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +278
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +732
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +85
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1057
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +196
   System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +146
   System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +16
   System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +94
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +110
   System.Data.SqlClient.SqlConnection.Open() +96
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +121
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +316
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +86
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1474
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138
   System.Web.UI.WebControls.ListView.PerformSelect() +167
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105
   System.Web.UI.WebControls.ListView.CreateChildControls() +122
   System.Web.UI.Control.EnsureChildControls() +83
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974

Connection string (web.config):

<add name="OracleDB" connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=srv00)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=seln)));User Id=USR;Password=Password.USR;" />

SqlDataSource code:

<asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:OracleDB %>" runat="server"
    SelectCommand="SELECT Field1, Field2, Field3 FROM ban.fj_table WHERE Field1= :Field1"

And SELECT parameter of SqlDataSource:

<SelectParameters>
    <asp:ControlParameter Name="Field1" ControlID="CntrlName" PropertyName="SelectedValue" />
</SelectParameters>

There's no code in code-behind for this operation. Thanx for any help.. And sorry for poor eng (:

12
  • Where is the providerName in your SqlDataSource? See msdn.microsoft.com/en-us/library/92ceczx1(v=vs.85).aspx Without it your SqlDataSource cannot know which library use and defaults to Sql Server. Commented Dec 1, 2016 at 11:29
  • you're trying to connect to an Oracle DB using the .NET code libraries designed for accessing SQL Server . Use the Oracle libraries instead. Commented Dec 1, 2016 at 11:31
  • @Igor, I have "using Oracle.ManagedDataAccess.Client;" and asp:SqlDataSource must work with Oracle: msdn.microsoft.com/ru-ru/library/92ceczx1(v=vs.85).aspx Commented Dec 1, 2016 at 11:32
  • @ADyson, I'm using ODP library at all.. Commented Dec 1, 2016 at 11:33
  • 2
    @SPNick as the documentation is pretty clear on, the correct string to use for Oracle DBs is providerName="System.Data.OracleClient" See msdn.microsoft.com/en-us/library/… and also msdn.microsoft.com/en-us/library/92ceczx1(v=vs.85).aspx . Have you actually read any of the docs for the tools you're trying to use? Commented Dec 1, 2016 at 14:38

1 Answer 1

4

The comments of ADyson and Steve solved the problem for me, but due to the lack of format of comments, I wanted to post it as a "real" answer.

Assuming your connection string is correct, the problem is caused by not specifying the correct provider name and ASP.NET will assume it is SQL Server.

The provider name you have to use is "Oracle.DataAccess.Client". You may also need to add the reference to "Oracle.DataAccess" to your project first, if you haven't done so already.

<asp:SqlDataSource
    ID="SqlDataSource1"
    ConnectionString="<%$ ConnectionStrings:OracleDB %>" 
    runat="server"
    ProviderName="Oracle.DataAccess.Client"
    SelectCommand="SELECT Field1, Field2, Field3 FROM ban.fj_table WHERE Field1= :Field1">
</asp:SqlDataSource>

Be aware that Visual Studio might suggest "System.Data.OracleClient" as provider name, but this resulted in

System.Data.OracleClient.OracleException: ORA-00903: invalid table name

So you must use the provider from Oracle.

Sign up to request clarification or add additional context in comments.

3 Comments

Which is why reading the ADO.NET manual and tutorials is a good idea
@PanagiotisKanavos But who has time for that? It much faster to just modify a DevExpress sample project and google the error messages until it works. Oh, wait ...
With Oracle.ManagedDataAccess the provider string is Oracle.ManagedDataAccess.Client

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.