Can connect to mySql server via php but not with c# [duplicate] - c#

This question already has answers here:
How to form a correct MySQL connection string? [closed]
(3 answers)
Closed 8 years ago.
As I wrote in the topic, this works totally fine:
mysql_connect("server","username","password");
But this doesn't:
MySql.Data.MySqlClient.MySqlConnection connection =
new MySql.Data.MySqlClient.MySqlConnection("SERVER=server;DATABASE=database;UID=username;PASSWORD=password;");
connection.Open();
The exception is always
Unable to connect to any of the specified MySQL hosts
And no, the question is neither a duplicate, nor answered there

As per the documentation, this
"SERVER=server;DATABASE=database;UID=username;PASSWORD=password;"
should be
"SERVER=server;DATABASE=database;UID=username;PWD=password;"

Related

How to connect to a distant mysql database using asp.net [duplicate]

This question already has answers here:
Connecting to a mySQL database using asp.net
(2 answers)
Closed 6 years ago.
I want to connect to a disant mysql database wich is located in another server using Asp.net C#.
How can i did it ?
Thanks.
You need this code:
var myConnectionString = "server=127.0.0.1;uid=root;pwd=12345;database=test;";
var conn = new MySqlConnection(myConnectionString);
conn.Open();
Also you need the public IP of the MySql server and the correct credentials (userid, password and database name).

Invalid connection string [duplicate]

This question already has an answer here:
SQL Server connection string
(1 answer)
Closed 6 years ago.
Apparently this connection string is incorrect?
connectionString="Server=mydb.com:1433/sqlExpress;Database=d;User Id=d;Password=pw;"
the first think that I see is that you have type wrong this part
Server=mydb.com:1433
use
Server=mydb.com,1433
the sql server use the comma to separate the port.
Also take a look at that answer: Setting up connection string in ASP.NET to SQL SERVER

SQL Server 2008 R2 connection string error [duplicate]

This question already has answers here:
ExecuteReader requires an open and available Connection. The connection's current state is closed
(3 answers)
Closed 8 years ago.
I have a SQL Server 2008 R2 running but when I try to connect to the server via my C# connection string I receive an error. I have no clue of what the problem is!
Here is my connection string:
_msConnection = new SqlConnection("Server=ServerIpAdress;Database=DataBaseName;User Id=NetworkName\\UserName;Password=PW;");
I hope some of you guys can help me?
Have a great day you all!
Id=NetworkName\\UserName
sounds a bit strange, try
Id=username
Also if you can connect to the DB using MS VS, MS SMS or any other likely tools your app can connect passin exactly same paramenters.
Other things to check: Actual user running the app (IIS_USR maybe)
In your SMS or VS you can get the actual connection string being used and just copy past it.

Check the SQL Server database & table size [duplicate]

This question already has answers here:
Determine SQL Server Database Size
(8 answers)
Closed 9 years ago.
How can one check the SQL Server database and table size (in MB) using C#?
Have you looked at the sp_spaceused stored procedure?
Just execute it with DBName.Tablename.
Here is the MSDN Link

IPC problem in the c# - ipc is already registered [duplicate]

This question already has answers here:
The channel 'tcp' is already registered
(3 answers)
Closed 8 years ago.
I am trying to create two IPC channels
IpcChannel ipcChannel = new IpcChannel("DroolsClient");
ChannelServices.RegisterChannel(ipcChannel, false);
objec = (DroolsInterface.RulesEngineInterface)Activator.GetObject(typeof(DroolsInterface.RulesEngineInterface), "ipc://Drools/SreeniRemoteObj");
IpcChannel ipcChannel2 = new IpcChannel("ProxemClient");
ChannelServices.RegisterChannel(ipcChannel2, true);
objec2 = (ProxemProject.ProxemInterface)Activator.GetObject(typeof(ProxemProject.ProxemInterface), "ipc://ProxemProcess/SreeniRemoteObj");
But when it gets to the second ChannelServices it gives an error
The channel 'ipc' is already registered
Would anyone be kind enough to help please
See this question Two-way communication using IPC
The channel 'tcp' is already registered

Categories