Repository navigation
Expand file tree
/
Copy pathConnectionDataBase.cs
More file actions
161 lines (141 loc) · 5.11 KB
/
Copy pathConnectionDataBase.cs
File metadata and controls
161 lines (141 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
using System;
using System.Collections.Generic;
using System.Text;
#region ---(Using Adicionais)
/// <summary>
/// SQL Using
/// </summary>
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
///
#endregion
namespace App_SQL_Conections
{
class ConnectionDataBase
{
#region ---(..........Metodo Contrutor..........)---
/// <summary>
/// Metodo Contrutor Conexao SQL Base
/// </summary>
public ConnectionDataBase()
{
}
///
#endregion
#region ---(..........MSQL_StringBuilde..........)---
private static SqlConnectionStringBuilder stringBuilderSQL = new SqlConnectionStringBuilder();
/// <summary>
/// Formador de Strings SQL --- GET Somente String e SET somente a String
/// </summary>
public static string SQLServer_1_StringBuilder ///1
{
get { return stringBuilderSQL.ConnectionString; }
set { stringBuilderSQL.ConnectionString = value; }
}
/// <summary>
/// STRING - Endereço Servidor Banco de Dados
/// O nome ou endereço de rede de instância de SQL Server a qual se conectar.
/// O número da porta pode ser especificado após o nome do servidor: (server=tcp:servername, portnumber)
/// </summary>
public static string SQLServer_2_EnderecoServidor ///2
{
private get { return stringBuilderSQL.DataSource; }
set { stringBuilderSQL.DataSource = value; }
}
/// <summary>
/// STRING - Nome Banco de Dados
/// O nome de base de dados pode ser caracteres 128 ou menos.
/// </summary>
public static string SQLServer_3_NomeBancoDeDados ///3
{
private get { return stringBuilderSQL.InitialCatalog; }
set { stringBuilderSQL.InitialCatalog = value; }
}
/// <summary>
/// STRING - Tipo de Login Conexao Banco de Dados
/// (Segurança integrada - ou - Trusted_Connection)
/// Quando false, a identificação de usuário e a senha são especificadas na conexão. (false --> SQL Server)
/// Quando true, as credenciais atual da conta do Windows é usado para autenticação. (true --> Windows)
/// </summary>
public static bool SQLServer_4_TipoSeguranca ///4
{
private get { return stringBuilderSQL.IntegratedSecurity; }
set { stringBuilderSQL.IntegratedSecurity = value; }
}
/// <summary>
/// STRING - Usuario Banco de Dados -
/// A conta de logon de SQL Server .
/// O identificação de usuário deve ser 128 caracteres ou menos.
/// </summary>
public static string SQLServer_5_LoginUsuario ///5
{
private get { return stringBuilderSQL.UserID; }
set { stringBuilderSQL.UserID = value; }
}
/// <summary>
/// STRING - Senha Banco de Dados
/// A senha da conta de abertura de SQL Server.
/// A senha deve ser 128 caracteres ou menos.
/// </summary>
public static string SQLServer_6_LoginSenha ///6
{
private get { return stringBuilderSQL.Password; }
set { stringBuilderSQL.Password = value; }
}
/// <summary>
/// STRING - Senha Banco de Dados
/// A senha da conta de abertura de SQL Server.
/// A senha deve ser 128 caracteres ou menos.
/// </summary>
public static int SQLServer_7_TimeOutConexao ///7
{
private get { return stringBuilderSQL.ConnectTimeout; }
set { stringBuilderSQL.ConnectTimeout = value; }
}
///
#endregion
#region ---(..........SQL_Connection..........)---
private static SqlConnection sqlServer_Connection = new SqlConnection();
/// <summary>
/// SqlConnection - SQL Conexao para Banco de Dados
/// </summary>
private static SqlConnection SQLServer_8_Connection
{
get { return sqlServer_Connection; }
set { sqlServer_Connection = value; }
}
///
#endregion
#region ---(..........Lista de Funçoes..........)---
/// <summary>
/// Funcao para Abrir Fechar e Outros para Renotar Conexao
/// </summary>
/// <param name="Open_Close_Status"></param>
/// <returns></returns>
public static SqlConnection SQLServer_FU_Connection(String Open_Close_Outros)
{
switch (Open_Close_Outros)
{
case ("Open"):
{
SQLServer_8_Connection.ConnectionString = SQLServer_1_StringBuilder;
SQLServer_8_Connection.Open();
return SQLServer_8_Connection;
}
case ("Close"):
{
SQLServer_8_Connection.Close();
SQLServer_8_Connection.Dispose();
return SQLServer_8_Connection;
}
default :
{
return SQLServer_8_Connection;
}
}
}
///
#endregion
}
}