问题
I created a database on freesqldatabase.com and was in the process of writing a C# script to connect to it and I cannot seem to get it to connect successfully. I think the issue is in the connection string, but I'm not sure what the problem is. I've been trying to get advice from documentation, but I haven't been able to fix it. My connection method is below:
Note: connAddr = sql3.freesqldatabase.com
Note: port = 3306
public static void Connect(string connAddr, int port)
{
CloseConnection();
Conn = new SqlConnection();
Conn.ConnectionString =
"Data Source=" + connAddr + "," + port + ";" +
"Initial Catalog=sql332572;" +
"user id=sql332572;" +
"pwd=xxxxxxxx";
Conn.Open();
}
I am getting the below error. Searching Google didn't seem to give me any information on this particular error:
Exception: Unknown packet type 91
Mono.Data.Tds.Protocol.TdsComm.GetPhysicalPacketHeader ()
Mono.Data.Tds.Protocol.TdsComm.GetPhysicalPacket ()
Mono.Data.Tds.Protocol.TdsComm.GetByte ()
Can you guys see anything wrong with my connection string? Any help is greatly appreciated. Thanks!
回答1:
Try using this format for your connection string:
Server=;Database=;uid=;pwd=;
回答2:
According to http://www.freesqldatabase.com/mssql/
they will launch MS SQL Server connection soon, i.e. they don't provide it now. What are you trying to connect to? If it is MySql than Sqlconnection would not work.
来源:https://stackoverflow.com/questions/22316254/cant-connect-to-remote-sql-server-in-c-sharp