private void DeleteExample() { Connection connection = new Connection(); connection.OpenConnection(); CommandSql command = new CommandSql(Resources.sqlQueryDelete, connection); command.Command.Parameters.AddWithValue("@studentId", 1); command.Command.ExecuteNonQuery(); connection.CloseConnection(); }
private void InsertExample() { Connection connection = new Connection(); connection.OpenConnection(); CommandSql command = new CommandSql(Resources.sqlQueryInsert, connection); command.Command.Parameters.AddWithValue("@studentName", "Alexis"); command.Command.Parameters.AddWithValue("@studentSurname", "Mengual Vázquez"); command.Command.ExecuteNonQuery(); connection.CloseConnection(); }
private void SelectExample() { Connection connection = new Connection(); connection.OpenConnection(); CommandSql command = new CommandSql(Resources.sqlQuery, connection); ReaderSql reader = new ReaderSql(command); string[] columns = { "StudentId", "Name", "Surname", "Birthday" }; string result = reader.ReadQuery(columns); connection.CloseConnection(); Console.WriteLine(result); Console.ReadLine(); }
public ReaderSql(CommandSql command) { Reader = command.Command.ExecuteReader(); }