I'd like to access an SQL database from within a Win32 application using C++. Does anyone have experience or suggestions on doing this?
I'd like to access an SQL database from within a Win32 application using C++. Does anyone have experience or suggestions on doing this?
I've used C to access MySQL. It was pretty straight forward. I can share my example if you want.
In my day job, I work with a very large RDBMS, and C++ is one of the languages for which we provide an API - I just haven't gone there yet. All my work has traditionally been accessing the db via Assembler, and I've just gotten into Java as well.
What RDBMS did you have in mind? Do you have any installed? Windows?
Mainframe assembler programmer by trade. C coder when I can.
Im going to use SQL, since I already have access to an SQL database system on my website and thus wont have to set anything up other than create another database ( I already have one but dont want it corrupted).
I think what Dino was trying to say is "which SQL variant are you looking at", as they are very similar but not the same, so you usually have to know if it's MySQL (which there is easy access C code to use - and of course C code can be wrapped in a C++ wrapper if you want), MS Access (which I'm sure MS has access (no pun intended) functions for), or for example Oracle or DB2, which I'm sure the respective companies have interfaces for in C and/or C++.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
I use ODBC
Connect using a DSN to hold site specific DB settings.
MFC makes this a 2 min job.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Yes, I will unfortunately have to use MFC for this task, but I will probably wrap it in a DLL so I can access it from non-MFC code.
ODBC is not a database, but merely a protocol (API) for accessing a database. See here: http://en.wikipedia.org/wiki/Odbc
SQL is the language to tell the relational database system what you want. Different DBMSs support different flavors of SQL.
Which database will you be using? Or, perhaps you don't know yet because you haven't picked one or don't know what is available.
Mainframe assembler programmer by trade. C coder when I can.
Yes ODBC is used to access most types of DBs. Which is what the OP asked for.
The differences in actual SQL between different versions is minor. In most cases it will not matter.
Or know it is irrelevant to the discussion, based on the design used/application requirements.
EDIT: I think you are under-estimating our experience.
Last edited by novacain; 11-20-2008 at 05:51 AM.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
u could also use OLEDB
http://msdn.microsoft.com/en-us/libr...84(VS.85).aspx