Solved

Connecting CEdit to database field

Posted on 2001-08-01
4
192 Views
Last Modified: 2013-11-20
i have a CEdit control, i need  to add properties to this control to make it able to connect a database and bound it to specific table field ( just like bounding a text field to table filed from a Data control in Visual basic)
0
Comment
Question by:raqadi
4 Comments
 
LVL 4

Expert Comment

by:IainHere
ID: 6339542
Well derive a class from CEdit, give it a member variable which is a CRecordset (or similar), and a few member functions - one which accepts a connection string in SQL for instance.  Catch OnLoseFocus event and update the database/recordset with the altered text.  to It really depends on your needs.

Is there only going to be one edit control in your application that connects?  Give it a CDatabase.

Are there going to be lots of edits connecting to a database?  Give them each a recordset and connect them to a common CDatabase.

Are you only going to be viewing text, or will you need to handle booleans and integers and dates etc? You'll need some validation, or else you'll get lots of "update failed" notifications from the database, which wouldn't be best practice.

This is only the beginning.  You're asking a lot - perhaps you'd like to narrow it down a bit?
0
 

Author Comment

by:raqadi
ID: 6339768
Hi,
im not developing a new application, im developing an ActiveX control inhirited from CEdit, and i want my control to acts like the TextBox that exist in Visual basic according to any data control exist in the form.
0
 
LVL 2

Expert Comment

by:BogdyPtr
ID: 6442101
If your application connects to a database through a recordset you go to class wizzard , member variables tab and and map the recordset field to the edit box.
0
 

Accepted Solution

by:
raqadi2 earned 110 total points
ID: 6663124
try to go to the ClassWizard, go to the Text property, click Data Binding button, and make the property bindable. try the control after this modification, you will see that the needed properties added as needed.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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
sumNumber challenge 16 137
Window placement 17 85
sumHeights  challenge 17 73
changeXy challenge 13 87
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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