[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Remote Data Objects with VC++

Posted on 1999-01-16
4
Medium Priority
?
264 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

649 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