1
I want to make a button that when it is clicked is shown the information of SQL Server and say that it is connected (have to configure the file in 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 are right it says the most settings when SQL Server data is wrong, it stops working the program.
I took a code already ready I’m just trying to make it better, but I can’t do "If the data is wrong show the message".
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site.
– Maniero