Solved

Remote Data Objects with VC++

Posted on 1999-01-16
4
253 Views
Last Modified: 2013-11-20
How do I use Remote Data Objects (RDO) with Visual C++? Can anyone provide me an example(source code) or at least tell me where I can get the info?
I require the info very urgently, as I have to meet a deadline.
Thanks.
0
Comment
Question by:sna
  • 2
  • 2
4 Comments
 

Author Comment

by:sna
Comment Utility
My email id is sna-vsh@vashi.ltindia.com
0
 
LVL 1

Accepted Solution

by:
abidn earned 200 total points
Comment Utility
Hi

Here is a step wise way to get started (I am assuming you are fine with MFC. If you don't want to use MFC, then programming will be a lot difficult).

1. Create an ODBC DSN setup. I will assume as follows: DSN=abc;UID=xyz;PWD=123
2. Create a an empty project with MFC (share or DLL) no wizard.
3. Create a dialog or form with an edit box and a command button.
4. Write the code to create message maps for the window/dialog class. For instance, you may create a map for ON_WM_PAINT event. (I'd advise that you execute that paint event only once, for now, by lets say, having a class wide boolean which rememebrs whether or not OnPaint method has been invoked previously).
I will assume that the edit box you created has a CEdit* named m_ptxt1
5. Write a method which is invoked in the click event of the command button. Caption this command button, "Fetch" or something similar or whatever.
6. Enter the following code in the method created in (5) above:
CDatabase* db;
db = new Cdatabase;
if (db->Open("abc",FALSE,TRUE,"ODBC;DSN=abc;UID=xyz;PWD=123;"))
{
   CRecordset* rs;
   rs = new CRecordset(db);
   if (rs->Open(AFX_DB_USE_DEFAULT_TYPE,"select * from table1"))
   {
      char buf[255];
      rs->GetFieldValue(0,buf);
      m_ptxt1->SetWindowText(buf)
      rs->Close();
   }
   delete rs;
   db->Close();
}
delete db;

/* the above routine will simply fetch the first field from
the first record of the selected table. In general you are better of using class wizard to do the field mapping for you.*/
0
 

Author Comment

by:sna
Comment Utility
Hi Abidn,
I am not so well versed with databases. So please forgive my primitive questions. Is this the correct way to use Remote Data Objects with VC++? I mean, I could not find a single example after a long search on the net. People I asked told me that it was a very complex proposition just like using ADO with VC++. Something like "rdoconnection" & things like in ADO. I really don't know. Please enlighten me.
Could you also provide me with some source code for ADO use with VC++? I would really be grateful.
Hoping for a favourable reply.
Thanks & Regards.

0
 
LVL 1

Expert Comment

by:abidn
Comment Utility
Hi Sna

Thanks for accepting my answer.

I gave you a barebones approach to getting started. Yes, MFC makes it rather simple, isn't it? Especially when you get the help of wizards. As to source for ADO, I suggest that you ask a separate question so that we keep the format of this site intact. tks -an.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 29
Best tools for Backup and restore of Wordpress site 6 53
sum67 challenge 35 88
fix34  challenge 9 95
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now