Wrap-Up

The main goal in all of this was to give you usable examples of code in C# for working with databases. Hopefully, if you had been working in Classic VB or VBA, you have found this helpful. As I stated earlier, I had the idea to write this when I found some items so difficult with very little in the way of help online. Once I figured it out, it took two or three lines of code to do what I needed. In the past, you could always count on good example code shown in context in help. With C#, there are some good examples, but many either just show the method you are looking up and the different overloads it takes, or the example will be against some static data that they load at runtime. While that is certainly better than nothing, I felt that some better examples with code that is shown in context would get people going. On most of the topics covered, there are so many more details, properties, methods, etc., that you can access. I suggest that you explore those as you go. Once the object is available, you can explore very easily.

One other thing that you may have noticed is that I don’t write examples that write to the console. Typically, I create a form and have a text box to take the value or I show it in a MessageBox. You could change any of the message boxes to write to the console. For me, I like the break in the action of the program to let me see what is going on. It isn’t something that I would have in live code for an application for a client, but for debugging, I ...

Get C# Database Basics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.