Solved

Connecting CEdit to database field

Posted on 2001-08-01
4
166 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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 video discusses moving either the default database or any database to a new volume.

763 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

11 Experts available now in Live!

Get 1:1 Help Now