Connection to Oracle database not working - c#

I am currently working on a project with someone. We are connecting to a oracle Database using the NuGet Package Oracle.ManagedDataAccess.Core.
We are connecting using a connection string that looks like this:
"User Id={this._dbUser};Password={this._dbPassword};Data Source={this._dbServer};"
The Parameters we pass on are correct we checked multiple times.
At first I got a Connection Timed out error which we fixed by adding persist security info=false;Connection Timeout=120; to the connection string.
At first it seemed to be working but then we encountered a new error.
This time it was saying:
Oracle communication: Connection to server could not be established or connection string not parsed
(Might not be 100% accurate because I had to translate it from German to English)
We could not find a solution for this error but we discovered that the error only gets thrown when we run the code on my machine. His is doing totally fine and can connect without any problems.
Could it be that I have some settings set on my machine that would prevent me from accessing the Database?

Related

MongoDB throwing exception on resolving connection string (C#)

I'm building a winform app that initially connects to a MongoDB server using Driver 2.10.
When I try and connect on my own machine everything works smooth, but when trying to install
clients on other computers via a msi file, the app crashes and I get the following:
ERROR - List of configured name servers must not be empty.
Parameter name: servers
at DnsClient.LookupClient.QueryInternal(DnsQuestion question, DnsQuerySettings queryOptions, IReadOnlyCollection`1 servers)
at DnsClient.LookupClient.Query(DnsQuestion question)
at MongoDB.Driver.Core.Configuration.ConnectionString.Resolve(Boolean resolveHosts)
at MongoDB.Driver.MongoUrl.Resolve(Boolean resolveHosts)
at MongoDB.Driver.MongoClientSettings.FromUrl(MongoUrl url)
at MongoDB.Driver.MongoClient..ctor(String connectionString)
at PaladinFormV2.MongoCRUD..ctor(String i_database)
at PaladinFormV2.Paladin..ctor(Boolean onboarding)
at PaladinFormV2.Program.Main()
I'm connecting through a connection string as follows:
MongoClient client = new MongoClient("mongodb+srv://[name]:[pass]#mcsamples-nwups.mongodb.net/test?retryWrites=true&w=majority");
What am I doing wrong and what information am I missing here to solve this?
Thanks
So after a long time trying to figure out what went wrong here, I came to the conclusion that using the '+srv' inside the connection string tries to resolve the DNS server on which your mongo instance is running, for clients using this it may cause the app to crash.
My fix was using a different connection string that does not use this prefix.
The info on connection string was taken from here https://docs.mongodb.com/manual/reference/connection-string/
Edit your connection string
From
`MongoClient client = new MongoClient("mongodb+srv://[name]:[pass]#mcsamples-nwups.mongodb.net/test?retryWrites=true&w=majority")`
To
`MongoClient client = new MongoClient("mongodb+srv://[name]:[pass]#mcsamples-nwups.mongodb.net/test")`
Also make sure you have internet connection to the cloud server

Unable to connect to master or target server "ServerName"

Have some troubles with Unit Test and Dackpack. This is the full error name:
DeploymentFailedException: Unable to connect to master or target server 'DBTests'. You must have a user with the same password in the master or target server 'DBTests'.
I have 3 strange things :
I can publish my Database on Server (tests have the same connection string)
I can log in in my site and I don't have troubles with DB (using IIS)
Test logic: Test database created when I init my tests, and it is really created!!!!
But all tests have "Error".
I upgrade my SSDT. I reinstall MSSQL Twice. And I set compability level(130). And what is so funny this is my Connection Strings when I try to debug my tests:
"Data Source=ServerName;integrated security=false;Initial Catalog=DbTests;User ID=kek;Password=kek;Connection Timeout=60;MultipleActiveResultSets=True;Max Pool Size=1024"
That is TestDatabase connection string. And she is absolutely fine because I TESTED this connection string.
This is masterDatabase connection string:
Data Source=ServerName;integrated security=false;Initial Catalog=master;User ID=kek;Password=kek;Connection Timeout=60;MultipleActiveResultSets=True
And the main question what I have: Why Error say what 'DBTest' - this is a server ?? I mean, this is DB, not server.
Maybe someone knows about that, idk. That is so stupid and I can't understand what's wrong.
UPD: I solve my problem. Installed SQL Server 2016.
P.S. Ofc I can log in on the server with my "kek", "kek" credentials in Management Studio.

Error Database schema could not be retrieved for this connection

Edit: if you are downvoting can you at least tell me what Im missing so I can improve my question?
I have a website which uses a SQL Server database. It works fine when building both debug and release.
But if I add a new SqlDataSource to my project and try to configure it in design view, I get this error:
Database scheme could not be retrieved for this connection. Please make sure the connection settings are correct and that the database is online.
Failed to retrieve data for this request.
Failed to connect to server---------.
Login failed for user 'xxxxxx'.
Even if I configure the connection string with the connection-guide, test the connection and save, it fails afterwards when trying to configure the datasource.
Connection string:
Data Source=SERVER\SQLEXPRESS,61180;Initial Catalog=DBNAME;User Id=USERNAME;Password=PASSWORD;
So to clarify: The connection string works fine when running the website in both debug and release, and if I connect using SQL Server Management Studio, but the only place it doesn't work is when I try to configure the datasource in design view.
After a lot of trial and error I found out that I had to put Persist Security Info=True; into the connectionstring to get it to work.
First time in my 10+ years of programming that I encountered this problem.

Entity Framework: Server did not respond within the specified time out interval

I am trying to access remote Oracle database using vpn connection. Using Oracle Sql Developer tool I am able to connect the database. But when I use ADO.NET model and Devart dotconnect for Oracle, it gives me error that server did not respond with in specified timeout interval.
Any one has face this issue?
UPDATE: I increases the timeout to 60s from default 15s. Now I am getting error:
ORA-12154: TNS:could not resolve the connect identifier specified
1st Issue is quiet common that server did not respond in defined time, increasing the connection time should do the trick. For this just append
;connection timeout = 60; (here time in seconds) to your connection string.
2nd After your update looks like Tns is not resolved properly:
You can check:
Do the tnsping (DB name in tns ora file). See you should not get any error and connection should be ok.
If problem still persist check your oracle home in registry have the correct path in case you have multiple client.

Getting Connection lost contact even though a new connection is created

I'm writing an ASP.NET web application. The database is Oracle. I've recently noticed that if I leave the application open for a while without doing anything and then try to access the database I get "ORA-03135: connection lost contact" error. One reason I can think of first is the connection timeout but I create a fresh new connection, open it, do what I need to do and "finally" close it every time I access the database. What's more interesting is after I get this error, I don't have any problems any more with connecting to the database. Do you have any ideas as to what the problem might be?
Are you using a connection pool?
In this case you can get this behaviour because the Oracle Connection Pool returns a "disconnected" connection. Try adding Validate Connection=True; to your connection string.

Categories

Resources