If you drop a horse in water, it will swim--as will a wolf, a hedgehog, and a grizzly bear. Granted, these animals won't swim very elegantly, and they may run out of steam after a few minutes, but neither will they immediately plunge to the bottom of a given lake or river and drown. That's why the issue of whether or not dinosaurs could swim isn't intrinsically very interesting: of course dinosaurs could swim, at least a little bit, because otherwise they'd be unlike every other terrestrial animal in the history of life on earth. (After this article was written, researchers published a paper concluding that Spinosaurus was an active swimmer, perhaps even pursuing its prey underwater.)
Before we proceed further, it's important to define our terms. Many people use the word "dinosaur" to describe giant marine reptiles like Kronosaurus and Liopleurodon, but these were technically plesiosaurs, pliosaurs, ichthyosaurs and mosasaurs: closely related to dinosaurs, but not in the same family by a long shot. And if by "swim" you mean "crossing the English Channel without breaking a sweat," that would be an unrealistic expectation for a modern polar bear, much less a hundred-million-year-old Iguanodon. For our prehistoric purposes, let's define swimming as "not immediately drowning, and being able to climb out of the water as quickly as possible."
Swimming Dinosaurs - Where's the Evidence?
As you can guess, one of the problems with proving that dinosaurs could swim is that the act of swimming, by definition, leaves no fossil evidence. We can tell a lot about how dinosaurs walked by footprints that have been preserved in silt, but since a swimming dinosaur would have been surrounded by water, there's no medium in which it could have left a fossil artifact. (Many dinosaurs have drowned and left spectacular fossils, but there's nothing in the posture of these skeletons to indicate whether its owner was actively swimming at the time of death.)
It also doesn't make sense to infer that dinosaurs couldn't swim because so many fossil specimens have been discovered in ancient river and lake beds. The smaller dinosaurs of the Mesozoic Era were regularly swept up by flash floods, and after they drowned (usually in a tangled heap), their remains often wound up buried in the soft silt at the bottom of lakes and rivers. (This is what scientists call a selection effect: billions of dinosaurs perished well away from water, but their bodies didn't fossilize as readily.) Also, the fact that a particular dinosaur drowned is no evidence that it couldn't swim; after all, even experienced human swimmers have been known to go under!
With all that said, there is some tantalizing fossil evidence for swimming dinosaurs. A dozen preserved footprints discovered in a Spanish basin have been interpreted as belonging to a medium-sized theropod gradually descending into the water; as its body was buoyed up, its fossilized footprints become lighter, and those of its right foot begin to veer off. Similar footprints and trackmarks, from Wyoming and Utah, have also occasioned speculation about swimming theropods, though their interpretation is far from certain.
Were Some Dinosaurs Better Swimmers Than Others?
While most, if not all, dinosaurs were able to doggy-paddle for brief periods of time, some must have been more accomplished swimmers than others. For example, it would only make sense if fish-eating theropods like Suchomimus and Spinosaurus were able to swim, since falling into the water must have been a constant occupational hazard. The same principle would apply to any dinosaurs that drank out of watering holes, even in the middle of the desert (meaning that the likes of Utahraptor and Velociraptor could probably hold their own in the water as well).
Oddly enough, one family of dinosaurs that may have been accomplished swimmers were the early ceratopsians, especially the middle Cretaceous Koreaceratops. These distant forebears of Triceratops and Pentaceratops were equipped with strange, fin-like growths on their tails, which some paleontologists have interpreted as marine adaptations. The trouble is, these "neural spines" may just as well have been a sexually selected characteristic, meaning that males with more prominent tails got to mate with more females--and weren't necessarily very good swimmers.
At this point, you may be wondering about the swimming abilities of the biggest dinosaurs of them all, the hundred-ton sauropods and titanosaurs of the later Mesozoic Era. A few generations ago, paleontologists believed that the likes of Apatosaurus and Diplodocus spent most of their time in lakes and rivers, which would have gently supported their vast bulks--until a more rigorous analysis showed that the crushing water pressure would have virtually immobilized these huge beasts. Pending further fossil evidence, the swimming habits of sauropods will have to remain a matter of speculation!