Solved

Remote Data Objects with VC++

Posted on 1999-01-16
4
256 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand to include initial dialog with two choices. 9 80
substring method in java 1 129
sumHeights2  challenge 7 114
Bartender label printing - switch on and off graphics 3 54
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: 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.

808 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