|
You have the basic idea. The way that I do it is to pass the list control to the Doc and have the doc populate the list, that way the View doesn't need to know anything about the database. Something like this:
CDoc::AddCustomers( CListCtrl* pList )
{
// Reset the list control content
pList->DeleteAllItems();
// I'm assuming that you somehow get a CDaoRecordset for the Customer table
// and not accessing the database object directly.
m_MyDaoDB->MoveFirst();
while( m_MyDaoDB->IsEOF() != 0 )
{
// Add the record to the list
m_MyDaoDB->MoveNext();
}
}
Don't know if this is a better OO way, but the Doc should know about the data, and the view handles the UI. I like to keep access to the data in the Doc and the View handles the display and user interaction.
|
|
|
|
|
Is there a better way to get that list? (I mean more OO)
"More OO" solution is to create a public member in your doc class which takes CListBox reference as an argument and fills the window with database contents:
void CYourDoc::FillListBox(CListBox &lbx)
{
while (!m_MyDaoDb->IsEOF())
{
int idx = lbx.AddString(...);
lbx.SetItemData(idx, ...);
m_MyDaoDb->MoveNext();
}
}
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
How can I set CRichEditCtrl not to make automatic wrap (word break)?
|
|
|
|
|
Enable Auto HScroll.
/Per
|
|
|
|
|
Enable Auto HScroll.
/Per
|
|
|
|
|
I want to save in file the system time in format of:
____________
DWORD year
DWORD month
DWORD day
DWORD hour
DWORD minute
DWORD second
______________
Which func would give me this or how can I to extract only this data from the func: GetSystemTime() ??????????
|
|
|
|
|
Have you tried it yourself yet? GetSystemTime() will give you WORDs. If you're stuck, post your code so we can see what you've tried.
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
|
What is the difficulty?
Just copy the values you need and convert them to DWORDs.
I would have understand it if GetSystemTime gave you 6 WORDs and you wanted 8.
|
|
|
|
|
OK, I have made an app that parses a bunch of files and I have all the data
stored into various arrays.
I would like to be able to store this information into an Access database.
I have no clue where to start on accessing Access and writing information to
a database though. If anyone could help me out and point me in the right
direction I'd be greatful!
Adam
cabadam@houston.rr.com
|
|
|
|
|
If you use MFC, CDaoDatabase and CDaoRecordset may help you. With the class wizard add a new CMyDaoRecordset and map the database fields into class members. You find examples on MSDN.
|
|
|
|
|
OK, but it gives me 'unrecognized database format' when creating the class and selecting which database I want to use... I am using Access 2000. Will that not work?
Adam
cabadam@houston.rr.com
|
|
|
|
|
If you use Access 2000 you have to add an instruction in the CYourApp::Initinstance()
The instruction is:
AfxGetModuleState()->m_dwVersion = 0x0601;
This work if you are linking with the MFC DLL.
You can take a look at the Q236991 on MSDN for further details.
|
|
|
|
|
Your right, ClassWizard doesn't support Jet 4.0 formatted files. Either create the file in Access 97 or you will have to create the record sets and bind them manually.
There is another way to do this and use the generic recordset that is posted in the Database section. That is the way I go because I don't like all the recordset files that are required for each table within the file, source code can get quite large.
|
|
|
|
|
[snip]
There is another way to do this and use the generic recordset that is posted in the Database section.
[/snip]
What do you mean?
This is my first venture into doing anythign with databases (at least programatically, I HAVE used Access before )
I tried to look into the Enroll MFC sample, but it requires some database that you can't download from online (and I can't find my VStudio stuff right now...)
Adam
cabadam@houston.rr.com
|
|
|
|
|
In the Code Project's General section - Database area, there is an artical called "The CGeneric Database class".
What this does is allow you to use the CGeneric recordset without binding the columns the way Class Wizard does. You can either set/get the column data via the calls like GetBool( "Column Name" ); or GetBool( column number );
This is a Dynamic way to use DAO vs the static way that Class Wizard does it. Also if you add new fields to the table, you don't have to rework the code, just add the new Get/Set routines.
|
|
|
|
|
Visual Studio 6.0 Wizard don't support Access 2000. You must convert to Access 97 or use ODBC instead (Use CRecordset instead of CDaoRecordset)
|
|
|
|
|
How do I "paint" text/CString in an ActiveX window? A sample code will be helpful...Thanks!
|
|
|
|
|
Could somebody who's got the most recent Platform SDK please send me a couple of small files? I can't justify downlaoding the whole damned thing (or even a specific category) just for two files! Especially not from the UK on a 56k (~4kbs) connection I still havent' been able to order the CD, so this is my only option.
The files are:
DBGHELP.LIB
DBGHELP.DLL
.. and the header (if there is one).
Please post here if you can send them to me after sending them to stop me getting a mail box full of them.
Thanks in advance,
David Wulff
dwulff@battleaxesoftware.com
|
|
|
|
|
David, they’re on their way.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
I've finally figured out how to create a DAO Database, add the tables and add the fields to the tables, but I can't figure out how to add an index to a field.
Can someone give me a tumbnail sketch of how to attach an index to a field in a new database?
Thanks!
Richard
|
|
|
|
|
You do not add an Index to a field, but rather add the index to the CDaoTableDef using the field information. Use CDaoIndexInfo, CDaoIndexFieldInfo to define the index and then use CDaoTableDef::CreateIndex() to create the index in the table definition.
|
|
|
|
|
I'm having a heck of a time with this one guys so any points in the right direction or helpful tips will be greatly appreciated. I have used this 3rd party control a ton of times in Visual Basic (no flames ), it is written using VC++ and ATL. It compiles and builds fine, however, I get this error in occsite.cpp when running the application in debug mode "Unhandled Exception", and it breaks here:
DWORD COleControlSite::ConnectSink(REFIID iid, LPUNKNOWN punkSink)
{
ASSERT(m_pObject != NULL);
LPCONNECTIONPOINTCONTAINER pConnPtCont;
if ((m_pObject != NULL) &&
>>BREAK<< -> SUCCEEDED(m_pObject->QueryInterface(IID_IConnectionPointContainer,
(LPVOID*)&pConnPtCont)))
{
ASSERT(pConnPtCont != NULL);
LPCONNECTIONPOINT pConnPt = NULL;
DWORD dwCookie = 0;
if (SUCCEEDED(pConnPtCont->FindConnectionPoint(iid, &pConnPt)))
{
ASSERT(pConnPt != NULL);
pConnPt->Advise(punkSink, &dwCookie);
pConnPt->Release();
}
pConnPtCont->Release();
return dwCookie;
}
Here are the steps I have taken to get to this point. Added the control to a Dialog based application. Clicked on project->Add to project->Components and control. I click on the control in the Registered ActiveX controls (Oh, I used MFC and classwizard with dynamic link to MFC, and ActiveX support checked, and tried it with Automation support) select the control. Use the toolbox drag the control to a dialog, then use class wizard to assign it to a variable of type Control -> Class Name.
VC generated 4 wrapper classes, and then I build the app, no errors no problems, but when I hit F5 I get the error message above.
My assumption that all ActiveX controls, built on the COM architecture, are supposed to be interchangeable between enviornments. Is it possible this is not the case? Please post any help you can here, or feel free to email me, but I'm stumped on this one. I may have to use the C++ wrapper for the control, but shouldn't this step work?!?!
Thanks in Advance for any help!
Sam C
----
Systems Manager
Hospitality Marketing Associates
|
|
|
|
|
The above shouldn't say break, should of said ASSERTION in big bold letters
If anyone even has a guess to why this is happening or can explain to me why ActiveX controls aren't universal please do. Thanks.
Sam C
----
Systems Manager
Hospitality Marketing Associates
|
|
|
|
|
I need access to a CListBox variable which is in View.h, m_ctrlMyListBox, from various of my other classes. How can I get that?
|
|
|
|