private static DataTable RetornarGrid(string sql)
        {
            using (SqlConnection sqlConnection = new DTO.ConexaoSQL().Conectar)
            {
                using (SqlCommand sqlCommand = new SqlCommand())
                {
                    SqlConnection Connection = sqlCommand.Connection = sqlConnection;
                    Connection.Open();
                    sqlCommand.CommandText = sql;

                    SqlDataAdapter SDP = new SqlDataAdapter(sqlCommand);
                    DataTable      RTB = new DataTable();
                    SDP.Fill(RTB);
                    sqlConnection.Close();
                    return(RTB);
                }
            }
        }
Пример #2
0
        private void FprSqlMetodo(DTO_Aluno aluno, string str_Command)
        {
            using (SqlConnection sqlConnection = new DTO.ConexaoSQL().Conectar)
            {
                using (SqlCommand sqlCommand = new SqlCommand())
                {
                    SqlConnection Connection = sqlCommand.Connection = sqlConnection;
                    Connection.Open();

                    _ = sqlCommand.Parameters.AddWithValue("@nome", aluno.str_Nome);
                    _ = sqlCommand.Parameters.AddWithValue("@matricula", aluno.dec_Matriula);
                    _ = sqlCommand.Parameters.AddWithValue("@nome_escola", aluno.str_Nome_Escola);

                    _ = sqlCommand.CommandText = str_Command;

                    sqlCommand.ExecuteNonQuery();
                }
            }
        }