c# - System.InvalidOperationException: Internal Connection Fatal Error. when opening sql connection -
i've started playing around sql on c#, , i'm trying connect remote sql server. i've added ip list of hosts have remote access permission.
my code keeps producing error:
system.invalidoperationexception: internal connection fatal error.
@ system.data.sqlclient.tdsparserstateobject.trypocessheader<>
@ system.data.sqlclient.tdsparserstateobject.trypreparebuffer<>
@ system.data.sqlclient.tdsparserstateobject.tryreadbytearray<.byte[] buff, int32 offset, int32 len, int32& totalread>
the trace longer that, first few lines.
this code that's causing error (my actual connection string has correct username, password, , database name):
connectionstring = "data source=173.254.28.27,3306;network library=dbmssocn;initial catalog=mydatabase;user id=myusername;password=mypassword;"; using (sqlconnection myconnection = new sqlconnection(connectionstring)) { try { myconnection.open(); } catch (exception e) { console.writeline(e.tostring()); } }
any appreciated.
thanks!
edited
if using mysql server
connection string wrong!
try connectionstring :
_connectionstr = new mysqlconnectionstringbuilder { server = "173.254.28.27", database = mydatabase, userid = myusername, password = mypassword, connectiontimeout=60, port = 3306, allowzerodatetime = true }; _con = new mysqlconnection(_connectionstr.connectionstring); try { _con.open(); } catch { console.writeline("error, can't connected!"); }
if using sqlserver
try disabling connection pool through connection string!
by adding :
pooling=false
good luck!