Ok, I've been trying to research this, but have had no real luck for my level of understanding. I've been programming C++ for a while and have decided to learn DB programming (just because I want to). Anyhoo, I am unable to figure this one out:

I have a simple database written in the MS Visual Studio 2010 sqlexpress environment:
ACRONYMDB
The database has a single table:
ACRONYMTABLE
The table has three values:
int ACRONYMID (which is the primary unique key)
nvarchar(50) WORDNAME
nvarchar(10) ACRONYM
My query is "SELECT * FROM ACRONYMTABLE "

There is no username or password for the database, as I'm not worried about security just yet. My local-machine server for the database connection is "gandalf\sqlexpress.ACRONYMDB" and yes, I am a fan of Tolkien.

If it is not too difficult, is there anyone that could give me a quick rundown on how I can connect to and retrieve info from the database listed? Again, this is for my learning and all the searching on Google and Bing has resulted in a lot of blah that seems to be more confusing than not... at least to me.

Thank You in advance

I just googled "C++ ODBC example" and the first hit seems to be sufficiently useful. You will likely have to adjust various constants in the code, particularly the query and result handling in lines 55-69, and reformat it to match your own coding style (preferably without the goto's), but I'm betting it will work for you more-or-less as-is. If you run into problems, post your code back here and I'm sure somebody will be happy to help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.