How can I make a connection to SQL with the connectionstring in AppConfig?
I did this, but I wish it could be by AppConfig, how can I do it?
private void button1_Click(object sender, EventArgs e)
{
string connectionString = @"Data Source=SQL;Initial Catalog=Banco;Persist Security Info=True;User ID=sa;Password=Senha";
SqlConnection con = new SqlConnection(connectionString);
try
{
con.Open();
MessageBox.Show("Conectado com sucesso");
}
catch
{
MessageBox.Show("Erro ao conectar");
}
}