Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 18th, 2006, 02:46 AM
Registered User
 
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connectivity Between VC++ Apllication and MS Acces

Dear,

Can u all guide me that how i would develop the code for connectivity between VC++ and MS Access.

Thank and regards
Ashok Rana
Contact No 91-9867467652

 
Old September 23rd, 2006, 09:14 AM
Registered User
 
Join Date: Dec 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You're asking about connecting your VC++ program to an Access database, right?
Alright, I'll tell you how to do it from the IDE, which is simpler; then using code.

You'll have to use an OleDbConnection. Set its "ConnectionString" property to your Access database. If you've never set this connection before, you'll need to create a new one. Simply choose <New Connection> from the connectionString property. The data link property window will show up; go to the "Provider" tab, select "Microsoft Jet 4.0 OLE DB Provider" from the list and click Next.
This will send you to the "Connection" tab, in the first edit box, select the Database. Then enter the User name and password in the other boxes. Click "Test Connection" (at the bottom) to make sure the connection is alright; then click OK.

To do it from code, here is a sample:

//Create the connection
OleDbConnection * conn = new OleDbConnection();

//Set the connection string
conn->ConnectionString =
S" Provider=Microsoft.Jet.OLEDB.4.0"
S"Data Source=C:\\temp\\myDatabase.mdb";

After this, everytime you need to read/write from/to the database, simply open the connection as such: conn->Open();
And don't forget to close it when done: conn->Close();

Hope this is what you were looking for.





Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Acces Autonumber teddyk ASP.NET 2.0 Basics 7 October 22nd, 2008 09:07 PM
Extract information from MS Word by VC++ avinashss VB How-To 1 November 28th, 2007 08:41 AM
connectivity between ms-access and vc++ umang.cs Visual C++ 0 May 1st, 2006 10:07 AM
Getting Problem in DATE/TIME Data type in MS Acces selam70 Classic ASP Databases 2 September 4th, 2004 02:31 PM
VC++ ActiveX Property Pages in MS Excel higgie Visual C++ 0 July 6th, 2004 09:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.