?
Solved

Remote Data Objects with VC++

Posted on 1999-01-16
4
Medium Priority
?
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

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

Accepted Solution

by:
abidn earned 600 total points
ID: 1327775
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
ID: 1327776
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
ID: 1327777
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 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