Solved

Remote Data Objects with VC++

Posted on 1999-01-16
4
254 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
ID: 1327774
My email id is sna-vsh@vashi.ltindia.com
0
 
LVL 1

Accepted Solution

by:
abidn earned 200 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 84
deburging in oracle form 12 87
ffmpeg - "rtsp://...... Operation not permitted" 4 73
sum67 challenge 35 93
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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
A short film showing how OnPage and Connectwise integration works.

943 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

5 Experts available now in Live!

Get 1:1 Help Now