Janek
Janek
CC#
Created by Janek on 6/6/2024 in #help
✅ Why I'm getting ArgumentException/System.Windows.Markup.XamlParseException exception?
No description
2 replies
CC#
Created by Janek on 5/28/2024 in #help
✅ Microsoft sql unable to connect. What I'm missing?
Hey! Does anybody know what I'm missing as I'm trying to connect to mysql? I get InvalidOperationExpection on SqlConnection.Open() function call. (System.InvalidOperationException: 'Internal connection fatal error.) Here is the ConnectionString: Data Source = "127.0.0.1, 3307"; Initial Catalog = mysql_db; User ID = root; Password = root Ip, port, db, username and password is correct as I was able to login as root use using MySQL Workbench software. GetBuilder function:
internal SqlConnectionStringBuilder GetBuilder()
{
return new SqlConnectionStringBuilder
{
DataSource = Server,
UserID = Username,
Password = Password,
InitialCatalog = Database
};
}
internal SqlConnectionStringBuilder GetBuilder()
{
return new SqlConnectionStringBuilder
{
DataSource = Server,
UserID = Username,
Password = Password,
InitialCatalog = Database
};
}
GetConnection function
internal SqlConnection GetConnection(SqlConnectionStringBuilder builder = null)
{
SqlConnection connection = null;
try
{
connection = builder == null ? new SqlConnection(GetBuilder().ConnectionString)
: new SqlConnection(builder.ConnectionString);
}
catch (Exception err)
{
Console.WriteLine($"ERROR::Db_Connection::GetConnection:: {err}");
}
return connection;
}
internal SqlConnection GetConnection(SqlConnectionStringBuilder builder = null)
{
SqlConnection connection = null;
try
{
connection = builder == null ? new SqlConnection(GetBuilder().ConnectionString)
: new SqlConnection(builder.ConnectionString);
}
catch (Exception err)
{
Console.WriteLine($"ERROR::Db_Connection::GetConnection:: {err}");
}
return connection;
}
SendQuery function calls GetConnection after connection.Open is called which gives me the error.
SqlConnection connection = GetConnection();
connection.Open();
SqlConnection connection = GetConnection();
connection.Open();
49 replies