Conectando no SQL SERVER com C#
Classe para Abrir e Fechar conexão com Sql erver.
using System;
using System.Data;
using System.Data.SqlClient;
namespace br.conexao
{
public class Conexao
{
private String connectionString;
private SqlConnection connection;
public void open()
{
connectionString = "ADICIONE AQUI SUA CONNECTION STRING";
connection = new SqlConnection(this.connectionString);
this.connection.Open();
}
public void close()
{
if (this.connection.Equals(null) == false)
{
if (this.connection.State == ConnectionState.Open)
{
this.connection.Close();
}
}
}
}
}
Comentários
Postar um comentário