|
How are null values in database fields dealt with in C++ ADO #import msado15.dll.
I can retrieve data and display it if there are no nulls in the data.
The sql stops displaying at a null and will not display anything after it.
(It's as if the null acts as a string terminator )
Part of script...
while(!pRecordset->GetEndOfFile()){
for(int loop=0;loop<precordset->Fields->Count;loop++)
{printf("Name is '%s'\n",
(char*) ((_bstr_t) pRecordset->GetFields()->GetItem((short)loop)->GetName()));
printf("Value is '%s'\n",
(char*) ((_bstr_t) pRecordset->GetFields()->GetItem((short)loop)->GetValue()));
}
}
Any help here would be great!
|
|
|
|
|
GetValue (from FieldPtr) returns a _variant_t reference which basically just wraps a VARIANT. The case you are performing here is not safe because the VARIANT can be set to type VT_NULL or VT_EMPTY which cannot be cast to char*. To do this corretly, you need to check the type of GetValue (ie. VT_NULL or VT_EMPTY indicates a NULL value.)
|
|
|
|
|
Can you point me in the right direction for the use of VT_NULL or VT_EMPTY in an example or two...?
Searching the net I cannot see the wood for the trees at the moment!
Thanks
|
|
|
|
|
_variant_t varValue = pRecordset->GetFields()->GetItem((short)loop)->GetValue();
if (varValue.vt == VT_NULL || varValue.vt == VT_EMPTY)
{
printf("NULL");
}
else
{
printf((char*)(_bstr_t)varValue);
}
|
|
|
|
|
Hi there:
I am willing to learn how to write a custom pure API control (something simple for a start: e.g. equivalent of CStatic).
Could you give me an idea where to start or where to get more information on these kind of things?
Thank you.
A reasonable man adapts himself to the world. An unreasonable one persists, trying to adapt the world to himself. That is why all the progress in the world depends on the unreasonable men.
|
|
|
|
|
You will need to look at RegisterClass in order to create a window class that can be used to create your window. CreateWindow in order to create an instance of your custom class. Windows procedures in order to apply the functionality that you need.
If you would like to build your custom control on top of an existing windows control, you could also look up window subclassing.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
What I am looking for is to avoid using MFC completely.
Can you be a little bit more elaborate, or even better, refer me to a specific example? Thanks.
A reasonable man adapts himself to the world. An unreasonable one persists, trying to adapt the world to himself. That is why all the progress in the world depends on the unreasonable men.
|
|
|
|
|
All of those functions that I mentioned previously are from the Win32 API. So you will not need to use MFC with those functions.
Creating a custom control is not much different than creating an application window for a raw Win32 application. One of the only differences is when you create your control, you create it as a child of another window.
Try creating a new Win32 Windows Application project in VC++. It will generate a set of basic code to create the application window. It shows how to use the functions that I mentioned, RegisterClass, CreateWindow, and the WindowProc.
You should be able to adapt the window class that they create into the control that you would like to create. Simply modify the styles, and add the functionality that you would like to provide in the WindowProc procedure to handle the windows messages the way that you want.
I am sorry that I do not have a more concrete example on hand.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
How can I create an MDI application with Win32 API?
A reasonable man adapts himself to the world. An unreasonable one persists, trying to adapt the world to himself. That is why all the progress in the world depends on the unreasonable men.
|
|
|
|
|
Once you have created the window that you will be using as the frame for your application, call CreateMDIWindow as a child of your main window. Then the windows that you create as a child of this MDI window will become MDI children.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Yes, but according to MSDN, for Multi-threaded apps, one should use CreateWindowEx. Since this is similar to CWnd::CreateEx, I just added WS_EX_MDICHILD to ExStyle but got the same result (the child window's title bar doesn't change color to signify activation; clicking on the icon, instead of Ctrl+F4 for Close, its still Alt+F4; & using Spy++, the child windows don't have the WS_EX_MDICHILD exstyle; adding the exstyle by ModifyStyleEx doesn't change a thing.
solutions?
Tnx
|
|
|
|
|
There are Win32 app examples in the Windows SDK.
|
|
|
|
|
Just wondered how many people out there program not for a job, but because they want to.
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|
|
I think this would be a hot topic if you post in lounge.;)
|
|
|
|
|
The Eclypse wrote:
Just wondered how many people out there program not for a job, but because they want to.
Me.
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
I do both - as a job, AND because I want to.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Pure hobby... for now
Cheers!
Marc
|
|
|
|
|
I do both, but I couldn't see doing anything else as a job. I love programming.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I love programming as a hobby, and am currently looking to do it as a job. I have just finished uni see and getting that first job is harder than I thought.....
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
I've created a resizable MFC dialog and when resizing (WM_SIZING) the contents don't appear in their places at all. In fact, everything becomes a gray resizing rectangle. When the operation is done, the stuff comes up as it should allways be.
Do you know how to make the toys visible all the time?
rechi
|
|
|
|
|
I think, calling the all Child controls Invalidate and Update will do it!
|
|
|
|
|
How can I alter the width of a treelist or treeview control header dynamically on the fly. I tried the following but it doesn't seem to work.
void CAdjustHeaderColumns::AdjustColumnTreeWidth(int mColns, CString mCName, CNewTreeListCtrl &mtree)
{
CRegKey reg;
CString g_registry;
g_registry.Format("%s%s", REG_ROOTDIR, COLDIR);
CNewTreeListCtrl* pTreeHeader = (CNewTreeListCtrl*) mtree.GetDlgItem(0);
ASSERT(pTreeHeader);
CString mWidth;
CString mDWidth;
LV_COLUMN lvc;
lvc.mask = LVCF_WIDTH;
//Get the Column info and fill the HDITEM structure
HDITEM hdi;
hdi.mask = HDI_WIDTH;
for (int i = 0; i < mColns; i++)
{
pTreeHeader->GetItem(i, &hdi)
m_dwdth.Format("%sHDW%d", mCName, i);
m_wdth.Format("%sHW%d", mCName, i);
if (reg.Open(HKEY_CURRENT_USER, g_registry) == ERROR_SUCCESS)
{
reg.Read(m_dwdth, mDWidth);
reg.Read(m_wdth, mWidth);
}
if (mWidth.IsEmpty() || mWidth == "0")
mWidth = mDWidth;
if (mWidth != mDWidth)
{
TRACE("[%d] is width", atoi(mWidth) );
hdi.cxy = atoi(mWidth);
pTreeHeader->SetItem(i, &hdi);
}
}
}
Thank-you
Sincerely,
RAH
|
|
|
|
|
I'm writing an MDI app and I'm having trouble getting File->New to create _MY_ Doc/View, not the generic blank CDocument/CView. I had this working and somehow I broke it and I'm stumped as to why. I've researched, compared code, etc.
In my InitInstance() I have:
<br />
CMultiDocTemplate *pDocTemplate = new CMultiDocTemplate(<br />
IDR_TEXTTYPE,<br />
RUNTIME_CLASS(MEditDoc),<br />
RUNTIME_CLASS(CMDIChildWnd),<br />
RUNTIME_CLASS(MEditView)<br />
);<br />
AddDocTemplate(pDocTemplate);<br />
<br />
MMainFrame *pMainFrame = new MMainFrame;<br />
if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return(FALSE);<br />
<br />
m_pMainWnd = pMainFrame;<br />
<br />
pMainFrame->ShowWindow(m_nCmdShow);<br />
pMainFrame->UpdateWindow();<br />
I have the ID_FILE_NEW message handled by my MMainFrame class. I also tried having it handled by my MApp class, but no change. The handler looks like:
<br />
void MMainFrame::OnFileNew() {<br />
CMDIChildWnd *pChildFrame = new CMDIChildWnd;<br />
<br />
LPCTSTR lpszEditClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW,<br />
LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_WINDOW+1), NULL);<br />
<br />
pChildFrame->Create(lpszEditClass, _T("Edit"), WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW,<br />
rectDefault, this);<br />
}<br />
Any ideas?
|
|
|
|
|
I have a project where debugging is checked under Link, I am bulging the debug version, and i'm ising the Microsoft format for debug info. Still, when my program crashes, it doesn't have any symbols, function names or line numbers.
Is there something I can do to fix it?
|
|
|
|
|
Make sure "C++->General->Debug Info:" and
"Link->Debug->Debug Info" also are correct.
/Magnus
|
|
|
|