general error: database 'T' not connected - c#

I am trying to connect SAP HANA database in MVC, but I'm getting this error.
general error: database 'T' not connected
This is the code for connection:
using (HanaConnection sqlConnection = new HanaConnection("Server='192.168.0.13:30015'; UserName='S'; Password='E'; DATABASENAME='T'"))
{
sqlConnection.Open();
}
What could be the cause of this? I also tried changing my port to
30013
but got this error:
Connection failed (RTE:[89006] System call 'connect' failed, rc=10061:No connection could be made because the target machine actively refused it.
I can connect with this connection string using PHP.

It seems like there is no tenant database named 'T' available. If you have not configured this tenant, please try to omit the databaseName property and simply connect using
new HanaConnection("Server='192.168.0.13:30015'; UserName='S'; Password='E'")
Based on the error messages it seems that port 30015 is correct as the first error is originating from the database itself and the second is not.

Related

I'm able to connect to my Postgres db with PGAdmin but not with npgsql (C#)

I'm able to connect to my remote server (Postgres), and my user is able to query tables.
When I'm trying to implement connection to this db I'm getting this error:
Unhandled exception. Npgsql.PostgresException (0x80004005): 28000: no pg_hba.conf entry for host "XX.XX.XX.XX", user "XXX", database "XXX", no encryption
using (var connection = new NpgsqlConnection(connectionString))
{
connection.Open();
Error is thrown in the open, I've tried many kind of connection string:
"Server=XXX;Port=5432;Timeout=1024;CommandTimeout=1024;UserId=XX;Database=XX;Password=XX;Database=XX"
"Host=XXX;Port=5432;Username=XX;Password=XX;Database=XX"
Same result at all the attempts.
I've asked to server owner to check pg_hba.conf, waiting for his response...
but I don't understand why PGAdmin is able to connect and not my C# NPG connection :/
Thanks
I need to connect to this remote postgres db.

.NET 6 C# Getting timeout attempting to connect to Snowflake database

Every time I try to connect to a snowflake database in .NET 6 using the Snowflake.Data NuGet package, I get a timeout after 120 seconds. I've tried it with all correct credentials in the connection string, as well as all incorrect credentials. No matter what the response is the same:
[2022-06-26T21:05:06.742Z] Snowflake.Data.Client.SnowflakeDbException (0x80004005): Error: Snowflake Internal Error: Unable to connect SqlState: 08006, VendorCode: 270001, QueryId:
[2022-06-26T21:05:06.743Z] ---> System.AggregateException: One or more errors occurred. (Error: Request reach its timeout. SqlState: , VendorCode: 270007, QueryId: )
My code setup looks like this to connect:
using (var conn = new SnowflakeDbConnection())
{
conn.ConnectionString = #"
ACCOUNT=<account>;
USER=<user>;
PASSWORD=<password>;
ROLE=<role>;
DB=<db>;
WAREHOUSE=<warehouse>";
_log.Information("Attempting connection to Snowflake...");
await conn.OpenAsync();
...
Every time after attempting to open the connection it hangs for 120 seconds then produces the above error. I've tried async and non-async as well as a bunch of different connection string properties. I also verified I was able to establish an outbound connection to another database with a regular SqlConnection and that worked with no issues. Not sure what could be going wrong.
Also ran the Snowcd connection diagnostic tool as descripted in the docs, results were all passing:
After much trial and error, adding the specific HOST value to the connection string was what fixed it for me. Specifying the full account with region for the ACCOUNT value did not work. Only when done under HOST. Although the GitHub documentation states that HOST is not required, specifying it with the region is the only thing that prevented timeouts on my end.

Npgsql Replacing Hostname in the Connection String

I'm trying to connect to a Heroku PostgreSQL instance using the npgsql NuGet package. I've a problem with the connection string – the hostname gets replaced with my computer's public IP (see the screenshot below). An exception gets thrown in the Open() method of the NpgsqlConnection stating that the host doesn't exist. The rest of the parameters specified in the string (username, password and the database used) get recognized correctly.
I've tried using Host, Server and server instead of host but that doesn't seem to change anything. The database is up and running as I can connect to it using DataGrip with the same connection details.
Thanks!
The error you are seeing is from the database, not the library. It is saying that pg_hga.conf doesn't have an entry to allow your ip address to have access. You can read more about this file here:
https://www.postgresql.org/docs/current/auth-pg-hba-conf.html

MySql and C#: No connection could be made because the target machine actively refused it 127.0.0.1:3306

I have been trying to connect to MySql Database and I keep having this error:
SocketException: No connection could be made because the target
machine actively refused it 127.0.0.1:3306
C#
MySqlConnection connection = new MySqlConnection("server=localhost;user=MyUsername;database=Mydatabase;port=3306;password=MyPassword;");
I tried to check if the problem is with my connection string but I tested more than 10 different formats and I keep getting this error.
what is weird is that I have a website and I use PHP to connect to the database and it works great without any errors.
PHP
$conn = new mysqli("localhost:3306", "MyUsername", "MyPassword", "MyDataBase");
Can you try adding the following and seeing if it helps?
TrustServerCertificate=True;Trusted_Connection=False;Encrypt=True;'
I got this error because MySQL server was not running on Windows 11.
So to start the service go to => Services => MySQL80 and press "Start the service"
Also make sure the SSL connection is possible between the Server and Client.

Can connect mysql database via navicate but cant from c# application

here is all info.
Step 1
Step 2- Error Msg
Step 3- connection String
I have tried without using port number but the problem is same. There is IP restrictions for remote login. but if it is because of IP restriction why am I able to connect with Navicat.
Code of C# where i'm getting error.
As per step 1 it seems the connection has been successfully established, but still you are unable to connect to the specific database. Check the name of the database or confirm that the database exists with the name supplied in the connection string. You can do that even by creating a connection from Navicat. If the database exists you will find it there.
Cheers
Maybe you should invoke mysqlcon.Open() before using mysqlcon.

Categories

Resources