Best way to connect to Sql server with MFC

Soooo, I'm starting this new job soon, where most of the code is obsolete MFC. The ultimate goal is to convert / rewrite to C# .

I'm a little rusty with MFC, so I write code to try to fix my memory. Anyway, it was interesting how best to connect to the SS2005 database with MFC. Back on the day that CDatabase through ODBC was the way to go, has this changed in the last few years? I see you can use ATL and ADO, but looked a bit, well verbose, to my liking?

+4
source share
1 answer

ATL user templates for OleDb are an option - run here . ClassWizard is still there to help you, so verbosity is not a big obstacle. Very soon you will need to use the code manually. There is a lot of careful rotation, for example, so that your command line has exactly the right number? Labels matching COLUMN_ENTRY for the accessor. Then you will probably have a million CopyToCommandFromObject and CopyToObjectFromCommand methods.

This application does not yet have access to data, and are you going to add it? If so, I would seriously consider introducing a modern DAL (ADO.Net, linq, if you're lucky to be in 2008) in a separate managed assembly and do some interactions.

+2
source

Source: https://habr.com/ru/post/1276332/


All Articles