I have a remote Oracle 11G server that I can connect to with SQL Plus and through Visual Studio's server explorer. However, when I use the same connection string in my C# code, I'm getting ORA-12560: TNS:protocol adapter error.
My connection string looks like this (already trying the completed expanded version):
Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.18.99.99)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=MYORADB)));User Id=myuserid;Password=MyPasswd;
My initial attempts to connect with a hostname instead of IP resulted in:
ORA-12545: Connect failed because target host or object does not exist
With the IP, address I get the protocol adapter error
ORA-12560: TNS:protocol adapter error
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
at Oracle.DataAccess.Client.OracleConnection.Open()
at TestConnection.Form1.btnTest_Click(Object sender, EventArgs e)
I am using Oracle.DataAccess version 2.112.1.0 from the 11g client install directory.
Is there something different between the way the server explorer connects than from within the code?
Related
I have a service that can pull data from a (LocalDB)\MSSQLLocalDB database. This works fine on my computer, but then I run the service on my AWS server, and try to pull data from the database I get this error:
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: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist.)
My connection code is this:
SqlConnection conn;
SqlCommand comm;
SqlConnectionStringBuilder connStringBuilder;
void ConnectToDb()
{
connStringBuilder = new SqlConnectionStringBuilder();
connStringBuilder.DataSource = #"(LocalDB)\MSSQLLocalDB";//"(LocalDB)\v11.0";
connStringBuilder.InitialCatalog = "WRESTLING.MDF";
connStringBuilder.Encrypt = true;
connStringBuilder.ConnectTimeout = 30;
connStringBuilder.AsynchronousProcessing = true;
connStringBuilder.MultipleActiveResultSets = true;
connStringBuilder.IntegratedSecurity = true;
string location = Directory.GetCurrentDirectory();
//Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
string temp = #"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='C:\App_Data\Wrestling.mdf';Integrated Security=True";
// string temp = #"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='F:\Projects\Bailey Service\Bailey Service\App_Data\Wrestling.mdf';Integrated Security=True";
conn = new SqlConnection(temp);
comm = conn.CreateCommand();
}
My database is in the same location on both my computer and my server. I have Microsoft SQL Server Management Studio installed on my server and I can connect to and view the Wrestling.MDF database on that server.
I have SQL Server (SQLEXPRESS) running on the server. but should it be SQL Server (MSSQLLocalDB) running? I do not see that one. Is that the problem? Or is it something else?
My service is running on the server, because I can pull data from it that is not in the database it is only the function that pull from the database that is not working on the server.
Update:
I in stalled the new version of SQL but I am still getting this same error :
enter image description here
enter image description here
I have tried :
//Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
// string temp = #"Data Source=MOXL0063\TEW_SQLEXPRESS; Integrated Security = True";
string temp = #"Data Source=(LocalDB)\v11.0;AttachDbFilename='C:\App_Data\Wrestling.mdf';Integrated Security=True";
// string temp = #"Data Source=(LocalDB)\MSSQLSERVER;AttachDbFilename='C:\App_Data\Wrestling.mdf';Integrated Security=True";
but nothing is working...
why?
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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IService1.nextmatch(DateTime item)
at Service1Client.nextmatch(DateTime item)
how do I find the right instance>
If you are using Amazon RDS Db need first to download the driver and then connect to your database. Maybe this link can help you to connect with your db.
Head over to https://www.connectionstrings.com/ and fix your connection information.(LocalDb) is not the same as a local SQL Server express. for which https://www.connectionstrings.com/sql-server/ gives.... ".\SqlExpress" as server. Which, btw., needs to have AttachDbFileName (does that still work? Not used Express for like 10 years) because it does NOT automatically attach an MDF file.
I'm using
- ASP.NET, C#, .NET 4.5.2
- Oracle.ManagedDataAccess
- Oracle.ManagedDataAccess.EntityFramework
- Oracle.DataAccess
- Server running Windows Server 2008 SP2.
My website uses Oracle.DataAccess in most parts (e.g. login, search data). I'm migrating some parts to Oracle.ManagedDataAccess (e.g. insert Permit data). The website work perfectly in both my computer and server. However, when it works about 3-4 days it will show error ORA-12154 from Oracle.ManagedDataAccess parts but Oracle.DataAccess parts still work correctly. I can login or search data but I can't insert Permit data.
My current solution is recycling Application Pool every 3-4 days and it will work again. Please suggest me. Thank you.
Here is some of exception.
System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> Oracle.ManagedDataAccess.Client.OracleException: ORA-12154: TNS:could not resolve the connect identifier specified ---> OracleInternal.Network.NetworkException: ORA-12154: TNS:could not resolve the connect identifier specified
at OracleInternal.Network.AddressResolution..ctor(String TNSAlias, String instanceName)
at OracleInternal.Network.OracleCommunication.DoConnect(String tnsDescriptor)
at OracleInternal.Network.OracleCommunication.Connect(String tnsDescriptor, Boolean doNAHandshake, String IName)
at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession, CriteriaCtx criteriaCtx, String instanceName)
--- End of inner exception stack trace ---
at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, CriteriaCtx criteriaCtx, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, CriteriaCtx criteriaCtx, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, CriteriaCtx criteriaCtx)
at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<Open>b__36(DbConnection t, DbConnectionInterceptionContext c)
i am trying to connect PDA to SAP using SAP Web Service.
my visual studio version is Visual Studio 2008 Professional Edition.
i followed this great tutorial Create/Consume SAP Web service using SOAP Manager
i have added web service in my C# project , please find the below code.
SAP_WSDL.z_web_service_name service = new PDA_APP.SAP_WSDL.z_web_service_name();
SAP_WSDL.ZmmBatchPutawayFromPhp data = new PDA_APP.SAP_WSDL.ZmmBatchPutawayFromPhp();
data.PBktxt = "Test";
NetworkCredential cred = new NetworkCredential();
cred.UserName = "XXXXX";
cred.Password = "******";
service.Credentials = cred;
service.Proxy = new WebProxy("IP" , 1);
SAP_WSDL.ZmmBatchPutawayFromPhpResponse response = new PDA_APP.SAP_WSDL.ZmmBatchPutawayFromPhpResponse();
response = service.ZmmBatchPutawayFromPhp(data);
after deploying i am getting exception(WebException was unhandled) as could not establish connection to network.
System.Net.WebException - {"Could not establish connection to network."}
Stack Trace:
" at System.Net.HttpWebRequest.finishGetResponse()\r\n at System.Net.HttpWebRequest.GetResponse()\r\n at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)\r\n at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)\r\n at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult)\r\n at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)\r\n at PDA_APP.SAP_WSDL.z_web_service_name.ZmmBatchPutawayFromPhp(ZmmBatchPutawayFromPhp ZmmBatchPutawayFromPhp1)\r\n at PDA_APP.login.button2_Click(Object sender, EventArgs e)\r\n at System.Windows.Forms.Control.OnClick(EventArgs e)\r\n at System.Windows.Forms.Button.OnClick(EventArgs e)\r\n at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)\r\n at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)\r\n at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)\r\n at System.Windows.Forms.Application.Run(Form fm)\r\n at PDA_APP.Program.Main()\r\n"
Status : System.Net.WebExceptionStatus.ConnectFailure
please help me out to solve this problem.
Looks like some networking issues from your client to the SAP SOAP server. Here is some tips and tricks to check connectivity between the client and server.
Use Ping And Tracert: The utilities can be used to check if the client can see the server. First try ping which is just a basic check if the server available on the client network. Keep in mind that some network restrict use of ping. Secondly try tracert(Trace Route). This utility will show you a list of IP that the client has to travel to to get the server.
If both the steps above work and you can confirm that the server is reachable on the network then you can try to do a telnet sessions from the client to the server on the port where the service lives. If you can connect then you DON'T have a network issue if you cannot connect you probably have a firewall issue between your client and server.
In Summary:
Try to ping it. If this is successful then telnet to it. If you cannot ping try a tracert to the server if this is successful then telnet to it.
I have solved this by myself , i have activated Web service which i created in soamanager in SAP using SICF T.Code it solved my issue. thanks all for the effort.
How to connect the oracle database as a backend in asp.net (C#)?
what is the connection string for it?
when i was trying to connect i got the below error:
ORA-12154: TNS:could not resolve the connect identifier specified
The actual connection string depends on the parameters of your server (ip, instance name, credentials, etc).
Here's a site with several 'example' connection strings for oracle:
http://www.connectionstrings.com/oracle
To connect to Oracle DB with .NET, best way is:
Install Oracle client
Configure tnsNames.ora
Reference .net project to Oracle.DataAccess.Dll (ODP.NET)
Create connection using OracleConnection object
I will not even go into other possibilities because this is golden standard for .net-Ora connectivity
I'm trying do build an application using the pocket pc emulator...
My goal is to connect to a sqlserver express db placed onto another pc
note that in a simple desktop program everything works fine, but in the smartphone program, when this code is run:
SqlConnection DatabaseConnection = new SqlConnection(#"Data source=SERVER\SQL2008;Initial Catalog=myDatabase;Persist Security Info=True;User ID=myUser;Password=myPassword");
DatabaseConnection.Open();
and when the Open is called, this is the error message:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, TdsParserState state)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, TdsParserState state)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Connect(String host, SqlInternalConnection connHandler, Int32 timeout)
at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin()
at System.Data.SqlClient.SqlInternalConnection..ctor(SqlConnection connection, Hashtable connectionOptions)
at System.Data.SqlClient.SqlConnection.Open()
where is the possible error?
the connection string into a desktop app works, the "\SERVER" pc is found by the smartphone simulator...
any ideas?