I want to make a button that when clicked is shown the SQL Server information and say that it is connected (have to configure the file in the XML Configuration File)
See below the code:
public class Functions
{
public static void conn()
{
string connectionString = Conn.tank();
using (SqlConnection connection = new SqlConnection(connectionString))
{
bool Open = true;
if (Open)
{
connection.Open();
Globals.UpdateLogs("Conexão testada:");
Globals.UpdateLogs("Status da Conexão : " + connection.State); //info
Globals.UpdateLogs("User : " + connection.WorkstationId); //info
Globals.UpdateLogs("Banco de dados : " + connection.Database); //info
Globals.UpdateLogs("Versão SQL : " + connection.ServerVersion); //info
}
else
{
Globals.UpdateLogs("O programa não está conectado em sua DataBase, verifique as configurações");
}
}
}
In case it works right when you press the button and the data is right it says more settings when the SQL Server data is wrong, it stops the program from working.
I've got a code ready so I'm just trying to make it better, but I can not do it. "If the data is wrong, show the message."