Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 18th, 2006, 02:46 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old September 23rd, 2006, 09:14 AM
Registered User
 
Join Date: Dec 2005
Location: , , .
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:33 PM.


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