|
Here's what's going on:
1. It has nothing to do with any header file.
2. Why do you use a CMyDatabase object? Are you overriding some functionality of the CDatabase class?
3. If you are using a custom database object (CMyDatabase) make sure it is derived from CDatabase.
Voila!
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
i understand. my database object is derived from CRecordset .
isn´t there a possiblity to make the sql statement:
select distinct xy from mytable
with a database object from CRecordset ?
Because i ever use CRecordset ....
thank you very much
mfc
|
|
|
|
|
No.
You are making a fundamental confustion. A database consists of tables and when you retrieve a record you read data from one/or more table(s) from the database.
MFC ODBC classes are: CDatabase that wrapps around a database and CRecordset the wrapps around a table (or more tables).
If you want to make a SELECT DISTINCT xy FROM MyTable you have to create a database object that opens the database MyTable table is in, then you create a CRecordset object that takes a pointer to a CDatabase and you pass the SQL statement to that CRecordset (or CRecordset-derived) object. Then you can navigate via MoveNext, MoveLast etc. through the database.
You can, however, execut SQL commands to the database objects. These are generally DELETE or INSERT statements (but not SELECT):
CDatabase db;
db.Open (...);
CString MyDelStr = _T ("DELETE FROM MyTable");
db.ExecuteSQL (MyDelStr);
CString MyInsertStr = _T ("INSERT INTO MyTable Values.....");
db.ExecuteSQL (MyInsertStr);
I hope I've been helpful!
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
thank you very very much.....
i tried your idea....
<br />
CDatabase db;<br />
db.Open(_T( "Datenbank" ), FALSE,FALSE, _T( "ODBC"));<br />
CRecordset rs(&db);<br />
rs.Open(CRecordset::forwardOnly ,"Select distinct xy from Mytable");<br />
i connectet access and vc++ with ODBC. the ODBC driver from my database i namend: 'Datenbank'.
in my database i have different tables and one is called xy.
in my code (above) must be a mistake....it doesnt work...why?
how can i get the strings which i read out of my database table?
thank you.
mfc
|
|
|
|
|
Let me also suggest CODBCRecordset. This class encapsulates CRecordset and makes things much more accesiable. IMO that is.
Cheers
***********************
Tony Fontenot
Recreational Solutions
tony@recsolutions.com
***********************
|
|
|
|
|
Dear girls and guys of TheCodeProject
I need to know how can I draw some geometric shapes (GDI or Direct3D) on top of a DirectShow managed, running or paused, multimedia video (AVIs and BMPs), using DirectX 8.1.
Could I get a IDirectDrawVideo and then IDirectDraw (but DirectDraw is deprecated)?
It could be the solution to use overlay filters (although they are more focused on DVD solutions) as IOverlay?
Must I migrate to XP (my platform is W2K) and then use the VMR system?
Thanks in advance.
|
|
|
|
|
Hi,
I'm sending multiple overlapped I/O requests to a USB device, which it handles dutifully - unless there's an error.
How should I detect that?
I guess I could just send the requests, and then WaitForMultipleObjects to wait for the I/O's to complete. However, I'm not sure what happens when one of the transfers fails - do I have to wait until the remaining transfers time out, etc..
Are there "known good" solution to this scenario?
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
I have a Dialog with a CTreeCtrl that has the TVS_CHECKBOXES style. When I try to initialize the tree control by setting some checkboxes in the OnInitDialog of the dialog the checkboxes are not set. I found out that this is a MFC bug. I haven't been able to find a working workaround for this problem. One thing I did find was setting the image list before calling SetCheck, but this does not seem to work either. Anyone knows a working sollution?
|
|
|
|
|
Clickety[^]
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
Thanks for your reply, but I don't think this article covers my problem. I already tried to modify the style and then set the checkboxes, but still that does not work.
|
|
|
|
|
I thought I already added it...
Can't delve in deeper right now (@ work).
IIRC this one helps:
From InitDialog, Do a Postmessage(WM_APP)
Add a handler for WM_APP, and do the checkbox setting there
(I also have seen I've got to fix the project download )
Peter
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
Posting a message in the OnInitDialog does not seem to work either. The message is posted, the SetCheck is called, but still none of the checkboxes is checked.
|
|
|
|
|
Do you use SetitemState to set the check?
i.e.
void TreeCtrl_SetStateImage(CTreeCtrl & tree, HTREEITEM item, int stateImage)
{
tree.SetItemState(item, INDEXTOSTATEIMAGEMASK(stateImage), TVIS_STATEIMAGEMASK);
}
??
Note: 0 is "no state image", 1 is "unchecked", 2 is "checked" with the default state image list.
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
I tried SetCheck as well as SetItemState and I used 0, 1 and 2 but still it does not work...got any ideas left?
|
|
|
|
|
wow, that's tough...
There's an old version of the article on http://buerger.metropolis.de/bitbucket/howto/checktree.htm, with VC project that works (although there's a small bug in the hit test code, that probably doesn't matter for you)
Another comctl32.dll version (IE update or something) might be a good idea before spending much more time on it.
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
Sorry to bother you again, but the link does not work :
Die angeforderte Seite konnte nicht gefunden werden.
I run windows2000 sp2 and ie 5.5 (that should be sufficient, not?)
|
|
|
|
|
|
|
How's it going?
I updated the zip file (on the cherea.de site), so it's unpacks to a compilable project
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
Hi
Given a font and an rectangle I would like to know the best size of the font to acomodate a given text.
Can anybody help me?
Thanks
|
|
|
|
|
You may use CDC::GetTextExtent(text) which gives you the size of the text in pixels if drawn with the currently CDC-selected font.
HTH,
Ohé Partisans, Ouvriers et Paysans
C'est l'alarme!
Le Chant des Partisans
|
|
|
|
|
Yes, but I'm searching a general method to calculate the size of a font given a CRect and a text. There should be a relation between the size of the CRect in pixels and a given text to display in it (provided taht you have selected previously a font name)
Thanks
|
|
|
|
|
jmgir wrote:
There should be a relation between the size of the CRect in pixels and a given text to display in it (provided taht you have selected previously a font name)
I'm not sure of that, because the font name is not enough. When a CFont object is constructed, the system tries to match the criteria you asked with the available fonts, and if it doesn't match, the system with get the closest font, which may be different from what you asked.
Another point is that DC characteristics need to be part of the calculations, 'cause font use logical units when you need pixel and this conversion is relative to the DC characteristics.
Anyway, if you can get this formula, I would be happy if you could share it, TIA
HTH,
Ohé Partisans, Ouvriers et Paysans
C'est l'alarme!
Le Chant des Partisans
|
|
|
|
|
That ability may be exposed somewhere but I've not seen it.
I've resorted to constructing the desired font at various
point sizes and doing a binary search. It works ok since
I only need do this at the creation of the window wherein used.
|
|
|
|
|
how to i communicate between dialogs in a tab-control ?
my task is to notify another dialog to change its content
and notify the tabcontrol to show this other dialog and
hide the current.
i use the "CTabCtrlSSL - An easy to use, flexible extended tab control
By Derek Lakin"
has anybody an idea ?
|
|
|
|