Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi. I want to get data from Access database (.accdb). Does anyone has really one simple WORKING example for creating that OLEDB connection in VS2008 by using C++? I have done my googling work so far: gone through a lot of examples in web, but so far, I have not found any example which would be really WORKING. Thanks in advance ..

-Mike
Posted
Comments
JackDingler 4-Jan-12 10:18am    
Have you tried using the project wizard to create an app that connects?
Mikael Katajamaki 4-Jan-12 10:22am    
No, because I want to create everything programmatically. For that reason I do not want to use those wizards .. However, thanks for reply. Appreciated.
JackDingler 4-Jan-12 14:18pm    
If someone said that to me in a job interview, I'd count that against them.

In the business world we aren't given a lot of time to figure out how to make things work. Wizards are a good tool in your tool chest. The code they produce can teach you a lot about how Microsoft intended that their APIs be used.

Just saying.
Mikael Katajamaki 5-Jan-12 9:02am    
I wanted to create this programmatically, because by using wizards (as far as I know with my very limited knowledge) one does not necessarily learn anything about the object itself. By using wizard one is only learning how to use wizards. But what to do in the future, if the code breaks or something changes? If one does not understand anything about the object used in the code, one is useless. That's how I think at the moment. I have used ADO for the last 6 years in my VBA applications and about 2 years in C# applications and it's very easy there. However, using ADO in C++ seem not to be especially easy (at least for me). For that reason I wanted to have one simple working example I could study on my own.
JackDingler 5-Jan-12 12:02pm    
Right, if you don't look at the code the wizard produces, you won't learn anything from it.

The examples you'll find on the internet were probably constructed by the wizard, then maybe some changes were made... and likewise, if you don't examine the code in the example, you won't learn anything from it.

I've been doing ODBC for years. I recently had to dive headfirst into OLE DB, with no help. I generated classes with the wizard, examined the code, walked though them with the debugger, examined the existing OLE DB codebase and got my assignment done.

Check out this thread on social.msdn.microsoft.com:
connecting visual studio 2008 to access 2007 database[^]


If you haven't seen it yet, Data Programming with Access 2010 on MSDN[^] is also a great way to understand how to do this.


http://connectionstrings.com[^] is also a great resource for troubleshooting your connection strings.
 
Share this answer
 
v2
Comments
Espen Harlinn 4-Jan-12 11:28am    
Nice links :)
Mikael Katajamaki 4-Jan-12 12:11pm    
thanks
Here it is:Using ADO from C++[^]
This is a working sample of Database access via ADO (i.e. with Access, SQL Server). Though, you will need to add some methods to complete it.
It relies on OLEDB (if this is important to you). This is never as simple in native C++ as in managed languages.
 
Share this answer
 
v3
 
Share this answer
 
Comments
Mikael Katajamaki 5-Jan-12 8:52am    
thanks.
Wendelius 5-Jan-12 15:39pm    
Eipä kestä :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900