У меня есть эта начальная функция для подключения к моей базе данных
public static SqlConnection cnSqlConex;
public static bool cnOk = false;
public static void Iniciar_Conexion_BBDD(string Address, string Port, string Database, string User, string Psswd)
{
cnSqlConex = new SqlConnection(@"Data Source= " + Address + " , " + Port + "; Network Library= DBMSSOCN; Initial Catalog= " + Database + "; User ID= " + User + "; Password = " + Psswd);
try
{
cnSqlConex.Open();
cnOk = true;
}
catch (Exception e)
{
MessageBox.Show("Error al conectar a la base de datos " + e);
}
}
И это в форме.Используя правильные учетные данные, которые я использую в MySql Workbench, на другом ПК.
private string Address = "****";
private string Port = "3306";
private string Database = "****";
private string User = "root";
private string Psswd = "root";
private void btnAceptar_Click(object sender, EventArgs e)
{
Funciones.Iniciar_Conexion_BBDD(Address, Port, Database, User, Psswd);
if (Funciones.cnOk == true)
{
fPanel Ventana = new fPanel();
this.Hide();
Ventana.StartPosition = FormStartPosition.CenterScreen;
Ventana.ShowDialog();
this.Close();
}
else if (txtPsswd.Text == "Psswd" && txtUser.Text == "User")
{
fPanel Ventana = new fPanel();
this.Hide();
Ventana.StartPosition = FormStartPosition.CenterScreen;
Ventana.ShowDialog();
this.Close();
}
}
Но когда я пытаюсь войти в систему с правильными учетными данными, появляется эта ошибка, что я не могу понять, что не так.Я пытался удаленно подключиться к другим приложениям, и база данных, кажется, работает нормально.
Error al conectar a la base de datos System.InvalidOperationException: Error irrecuperable de conexión interna. Estado de error: 18
en System.Data.SqlClient.TdsParserStateObject.TryProcessHeader()
en System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(SqlAuthenticationMethod authType, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean& marsCapable, Boolean& fedAuthRequired)
en System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, Boolean isFirstTransparentAttempt, SqlAuthenticationMethod authType, Boolean disableTnir, SqlAuthenticationProviderManager sqlAuthProviderManager)
en System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover, Boolean isFirstTransparentAttempt, Boolean disableTnir)
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, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
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 Manejador_Datos_TFG.Funciones.Iniciar_Conexion_BBDD(String Address, String Port, String Database, String User, String Psswd) en C:\Users\Edu-PC\Desktop\Visual Basic Studio\Manejador Datos TFG_\Manejador Datos TFG\Funciones.cs:línea 22
---------------------------
Aceptar
---------------------------
Я немного тороплюсь, извините за формат или за некоторые ошибки.Я новичок в этом форуме, и сделал это сообщение, потому что я не могу найти никакого ответа.Спасибо за чтение в любом случае