What I have
- An account in http://www.freesqldatabase.com
- A database (DB_DATABASE var in my asp.net application)
- An user and password for the DB (DB_USER, DB_PASS)
- An Host URL (sql4.freesqldatabase.com [DB_SERVER])
- A catalog, plus three tables (DB_CATALOG)
- A port (DB_PORT)
What I aim
To connect from my asp.net app, to my database.
What have I tried
I tried to build a SqlConnection
, just like:
SqlConnection con = new SqlConnection(@"Data Source=(" + DB_SERVER + "\\" + DB_DATABASE + "," + DB_PORT + ");Initial Catalog=" + DB_CATALOG + ";UID=" + DB_USER + ";PWD=" + DB_PASS + ";");
I've used DB_DATABASE
as the instance name, but I'm not sure about that (any explanation to clarify me this mess would be apreciated!)
But I've also tried without it:
SqlConnection con = new SqlConnection(@"Data Source=(" + DB_SERVER + "," + DB_PORT + ");Initial Catalog=" + DB_CATALOG + ";UID=" + DB_USER + ";PWD=" + DB_PASS + ";");
And several options besides these ones, trying to modify the connection string, but no one has worked yet =(
What I obtain
Well, when I'm trying to open the connection, I'm getting the following exception (I've tried to look for any useful data here, but I'm not used to this yet...):
en System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
en System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
en System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
en System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
en System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
en System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
en System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
en System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
en System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
en System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
en System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
en System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
en System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
en System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
en System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
en System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
en System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
en System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
en System.Data.SqlClient.SqlConnection.Open()
en Gallery.Gallery.registerNewUser(String username, String encripted_password)
Plus, Found out
At http://www.freesqldatabase.com/category/net/ , they said they've said:
Due to a bug within some MySQL connectors, the ‘Out of sync with server’ error is returned.
To resolve this, use a different version of the MySQL connector.
But since I've seen nothing about this in the exception stacktrace, I'm not sure if I'm being affected by this (plus it's 2011 news).
Did I do something wrong when building the connection? How can I fix it?
Thank you in advance!