数据库连接 基本操作

private string strConn = "Data Source=WWW-ABB9DE1DEF5;Initial Catalog=MG_Admin;Persist Security Info=True;User ID=sa;Password=229524";
SqlConnection Conn;
SqlCommand myCommand;


private void ConnectionDB()
{
        if (Conn == null)
            Conn = new SqlConnection(strConn);
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
}
private void CloseConnection()
{
        Conn.Close();
}

你可能感兴趣的:(数据库,String,Security,null)