public static void AutenticationSqlSa(string servidor) { try { string ScripAutentiction = "USE [master]EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\\Microsoft\\MSSQLServer\\MSSQLServer', N'LoginMode', REG_DWORD, 2 USE [master] ALTER LOGIN [sa] WITH PASSWORD=N'123' ALTER LOGIN [sa] ENABLE Exec sp_defaultlanguage 'sa', 'us_english' Reconfigure"; CriaBancoRegraNegocio.novoBanco = new CriaBancoAcessoDados(); if (ScripAutentiction == null) return; CriaBancoRegraNegocio.novoBanco.Autentication(ScripAutentiction, servidor); } catch (Exception ex) { throw ex; } } public DataTable Autentication(string ScripAutentiction, string servidor) { SqlConnection sqlConnection = (SqlConnection)null; try { using (sqlConnection = new SqlConnection("Server= " + servidor + "; database=master;Integrated Security=True;Trusted_Connection = true;")) { sqlConnection.Open(); this.sql.Append(ScripAutentiction); this.comandoSql.CommandText = this.sql.ToString(); this.comandoSql.Connection = sqlConnection; this.comandoSql.CommandTimeout = 100;//500000 this.dadosTabela.Load((IDataReader)this.comandoSql.ExecuteReader()); return this.dadosTabela; } } catch (Exception ex) { throw new Exception("Ocorreu um erro no método VerificarBanco. Caso o problema persista, entre em contado com o Administrador do Sistema." + ex.Message); } finally { if (sqlConnection != null) { sqlConnection.Close(); sqlConnection.Dispose(); } } }