|
Thanks - I came to that conclusion last night ( I'd actually taken a book to bed, and was thinking about what I'd read when I bounded out of bed to solve the problem ). However, in my experience the exception for ADO is *always* unknown error and ADO flags don't offer much help either. I've grown to hate ADO with every failed attempt to pass perfectly valid SQL to it.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I have an IEnumXXX class, and another class which contains my database methods. Tonight I removed some unwanted methods from the database class based on help I got earlier today - no problems.
However, I started work on my MFC client for the database and discovered that now when I get any numeric data from my enumeration, the values are all garbage. Everything comes out with a value of 1. The database is fine, and the program used to return real values. Can anyone suggest what may have gone wrong ? I deleted the methods from the idl, .h and .cpp files, renumbered the methods so they ran from 1 with no gaps and rebuilt all. I had no errors or warnings.
#ifndef __SAFILEENTRY_H_
#define __SAFILEENTRY_H_
#include "resource.h"
class ATL_NO_VTABLE CSAFileEntry :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CSAFileEntry, &CLSID_SAFileEntry>,
public IDispatchImpl<ISAFileEntry, &IID_ISAFileEntry, &LIBID_SADATABASELib>
{
public:
CSAFileEntry()
{
}
CComBSTR m_FileName;
CComBSTR m_FilePath;
long m_FileLength;
long m_DownloadCount;
long m_LastModified;
long m_Frames;
long m_Seconds;
long m_Width;
long m_Height;
DECLARE_REGISTRY_RESOURCEID(IDR_SAFILEENTRY)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CSAFileEntry)
COM_INTERFACE_ENTRY(ISAFileEntry)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
public:
STDMETHOD(get_Height)( long *pVal);
STDMETHOD(get_Width)( long *pVal);
STDMETHOD(get_Seconds)( long *pVal);
STDMETHOD(get_Frames)( long *pVal);
STDMETHOD(get_Modified)( long *pVal);
STDMETHOD(get_DownloadCount)( short *pVal);
STDMETHOD(get_FileLength)( long *pVal);
STDMETHOD(get_FilePath)( BSTR *pVal);
STDMETHOD(get_FileName)( BSTR *pVal);
};
#endif //__SAFILEENTRY_H_
Only get_FilePath and get_FileName are working, and I've traced in to make sure the values in the class are indeed kaput.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
What is the code like for functions, get_Height for instance.
I guess it is a simple
(*pVal) = m_Height;
Or are you doing something else?
Michael
|
|
|
|
|
That is precisely what my GetHeight function looks like and the thing is, it used to work, but now if I break in the function, m_Height always equals 1. I know from opening it in access that the actual values are fine in the database, but now only the string values come out fine.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
What function fills the class variables with data? Does the data go into the class variables okay?
What happens if your initialise m_Height to 255 in the constructor? Does it still give 1?
Michael
|
|
|
|
|
If I make it 255 in the constructor, it still comes out as 1. If I make it 255 in the function, it comes out 255. I traced into my function that reads the data:
try
{
records->CursorType = adOpenStatic;
records->CursorLocation = adUseClient;
records->Open("SELECT * FROM FileDatabase",
_variant_t((IDispatch*)m_Connection, true), adOpenKeyset, adLockOptimistic,
adCmdUnknown);
}
catch(...)
{
}
records->MoveFirst();
vector<ISAFileEntry*> vecDatabase;
do
{
CComObject<CSAFileEntry>* pFileEntry = NULL;
CComObject<CSAFileEntry>::CreateInstance(&pFileEntry);
if (pFileEntry)
{
FieldsPtr spFields = records->GetFields();
string s = (bstr_t) spFields->Item["FileName"]->Value;
for (string::iterator it = s.begin(); it != s.end(); ++it)
if (*it == '?') *it = '\'';
pFileEntry->m_FileName = s.c_str();
pFileEntry->m_FileLength = spFields->Item["FileLength"];
pFileEntry->m_DownloadCount = spFields->Item["TimesDownloaded"];
pFileEntry->m_LastModified = spFields->Item["LastModified"];
pFileEntry->m_Width = spFields->Item["Width"];
pFileEntry->m_Height = spFields->Item["Height"];
pFileEntry->m_Frames = spFields->Item["Frames"];
pFileEntry->m_Seconds = spFields->Item["Seconds"];
and when the data comes out of the database and into the pFileEntry, it is already corrupted, they are already all 1's.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I'm not familiar with the database calls so this may be a stab in the dark,
your string is accessed via
string s = (bstr_t) spFields->Item["FileName"]->Value
yet your numbers are dont use the Value variable. Is this right
pFileEntry->m_Height = spFields->Item["Height"];
Michael
|
|
|
|
|
Well, how about that ? Thanks so much. I'm half way there now. The File Lengths are loading fine, but the properties I added most recently crash if I put ->Value after them. I guess it's back to the drawing board to try and figure out why.
Thanks again for all the help.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I needed to handle dialog button's events like WM_MOUSEMOVE and WM_RBUTTONDOWN, so i created a new class inherited form CButton and handled the events easily but the problem is that i couldn't find a way to access the parent dialog's functions so that i can change the dialog's properties, like for example changing a static text. Is there any way to hadle button's events and enable data exchange with the parent dialog?
|
|
|
|
|
GetParent will give you a pointer to the parent dialog CWnd class. You can then cast it to your dialog class.
CParentDialog* pParent = (CParentDialog*) GetParent();
|
|
|
|
|
I am trying to find some code which will enable me to find out what domain or workgroup a given host is in.
There is a function for this on Win2000, but I need it on NT4.
Does anyone have any ideas?
---
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
|
Nearly.
The link you posted (to NetWkstaUserGetInfo) gets info about the user's log-on domain info. However, just near this on MSDN was NetWkstaGetInfo which does the trick.
Thanks,
Paul.
---
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
When I created my SDI aplication it gives you the choice of having a status bar, if you select yes to this, when your program is created it creates a View menu with a status bar option inside. When you click on this option, a tick appears next to this if the status bar is shown and disappears if not. I wish to copy this functionality with another menu item but cannot work out how it does this in my program, any ideas?
Thanks in advance for any help,
Nick
|
|
|
|
|
On your OnUpdate handler
use
pCmdUI->SetCheck(m_bCondition);
|
|
|
|
|
In ClassWizard, select the command ID. Then, from the list on the right side, select UPDATE_COMMAND_UI. Create the handler. Inside the handler, call pCmdUI->SetCheck with TRUE or FALSE.
BTW: you should have a look on any MFC tutorial, like Scribble.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
thanks, that worked and I have been able to open and close this dialog from the view menu with the tick being displayed/hidden but how do I get the tick in the menu to disappear when the dialog is closed using the close button on the top-right of the screen. I can handle it using OnClose() in the dialog's class but how do I link it to the menu.
thanks for your help so far,
Nick
|
|
|
|
|
ON_UPDATE_CMD_UI handler is called whenever user opens the menu. You have to check the state of the program and pass correct value to CCmdUI::SetCheck.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I have an application, with several functions, and one of these have to return a pointer on COleDateTime. I know the size of the "array" of COleDateTime dates, 2, but i meet a problem when i start debugging when i look in the debug window.
When i declare in the function a COleDateTime pointer i could use 2 way to do that.
Firstly, i just could write:
COleDateTime pDates[2]; and in the debug window i could see:
pDates
[0]->m_dt
->m_status
[1]->m_dt
->m_status
and in another way i could do it:
COleDateTime *pDates=new COleDateTime[2];
and in debug window i only see that:
pDates
->m_dt
->m_status
So, what is the good way if i want to return 2 dates different?
Thanks in advance
gerald
|
|
|
|
|
You should be able to see the two dates in the debug window by modifing the debug view to look at,
pDates[0] and pDates[1].
There is no real difference between COleDateTime Dates[2] and COleDateTime* pDates = new COleDateTime[2] (apart from where the allocate memory goes)
Michael
|
|
|
|
|
Hello all,
as I mentioned I would like to display one (specified by me) member value of some class. You can observe this for MFC objects - e.g. CWnd displays value of m_hWnd in curly brackets.
I looked into definitions of some MFC classes (CWnd and CString) and didn't see anything 'magic'.
Does anybody know something about it?
Regards
Bartek
|
|
|
|
|
You mean in the debugger ? Just type it into the debug variable window.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Hmmm, I wrote bad topic
It's not so trivial ... I want to display value of specifed member while in 'Variable' window an object of the class containing this member is listed.
For example:
+this 0x00432990 {CManagersView hWnd=0x004604e6}
Class CManagersView is derrived from CView and automatically displays it's 'primary' member - m_hWnd.
Regards
Bartek
|
|
|
|
|
autoexp.dat located in <vstudio>\common\msdev98\bin contains the 'magic'.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
That's it!
Thanks a lot
Regards
Bartek
|
|
|
|