|
Trying the code you said, i receive the following error.
if (!pRs->IsEOF())
{
try
{
pRs->Delete();
}
catch(_com_error &err)
{
AfxMessageBox(err.Description());
return;
}
}
(I will make an english translation of the error code since i get it in Greeks)
"It was not possible to find the row for update.Its possible that some values have changed
since the last read."
What Seems to be the problem ? Below is the OnInitDialog() code and you can see the select query.
BOOL CBookProperties::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString strSQL,strVal;
wchar_t buffer[20];
m_Sheet.AddPage (&m_SheetBasic);
m_Sheet.AddPage (&m_SheetDetails);
m_Sheet.AddPage (&m_SheetExtras);
m_Sheet.AddPage (&m_SheetPhoto);
m_Sheet.Create (this, WS_TABSTOP | WS_CHILD | WS_VISIBLE,WS_EX_CONTROLPARENT);
m_Sheet.SetWindowPos (NULL,0,100, 0,0,SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
//NEW Record
if (m_mode == NEW)
{
m_bNext.EnableWindow (FALSE);
m_bPrevious.EnableWindow (FALSE);
m_bPrint.EnableWindow (FALSE);
m_bDelete.EnableWindow (FALSE);
}
else
//EDIT VIEW Record
{
pAdoDb = new CADODatabase();
try
{
if (pAdoDb->Open(((CLibrarianApp*)AfxGetApp())->m_strConnection))
{
pRs = new CADORecordset(pAdoDb);
_ultow( m_lRecSQLCode, buffer, 10 );
//find the specific record
strSQL=_T("SELECT Books.*, Categories.CategoryDesc, Author1,PublishHouses.PublishHouseDesc ")
_T("FROM books LEFT OUTER JOIN Categories ")
_T("On Books.CategoryID=Categories.CategoryID LEFT OUTER JOIN PublishHouses ")
_T("On Books.CategoryID=PublishHouses.PublishHouseID ")
_T("WHERE BookID=") + CString(buffer) + " "
_T("ORDER BY title,author1,categoryDesc ASC");
if (pRs->Open(strSQL,CADORecordset::openQuery) )
{
SetRecordValues();
UpdateData(FALSE);
m_lAbsRecPosition=pRs->GetAbsolutePosition();
pRs->Close();
}
else
{
pRs->Close();
delete pRs;
}
//now set a global query to use with next & previous button
strSQL=_T("SELECT Books.*, Categories.CategoryDesc, Author1,PublishHouses.PublishHouseDesc ")
_T("FROM books LEFT OUTER JOIN Categories ")
_T("On Books.CategoryID=Categories.CategoryID LEFT OUTER JOIN PublishHouses ")
_T("On Books.CategoryID=PublishHouses.PublishHouseID ")
_T("ORDER BY title,author1,categoryDesc ASC");
if (pRs->Open(strSQL,CADORecordset::openQuery) )
{
pRs->SetAbsolutePosition (m_lAbsRecPosition);
}
else
{
pRs->Close();
delete pRs;
}
}
else
{
pAdoDb->Close();
delete pAdoDb;
}
}
catch (CADOException &e)
{
pRs->Close();
pAdoDb->Close();
delete pRs;
delete pAdoDb;
AfxMessageBox(_T("Data base error.");
m_bError=true;
m_bNext.EnableWindow (FALSE);
m_bPrevious.EnableWindow (FALSE);
m_bPrint.EnableWindow (FALSE);
m_bDelete.EnableWindow (FALSE);
m_bOk.EnableWindow (FALSE);
m_bUpdate.EnableWindow (FALSE);
m_bCreateNew.EnableWindow (FALSE);
}
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
sdancer
|
|
|
|
|
I found the error, It was the Outter Join from the query !
Regards,
sdancer75
|
|
|
|
|
I have some doubt on DC operations in Windows.
1. When we call Invalidate() for any window, does WM_PAINT is sent to all child windows and child of child windows as well??
2. I have created a Compatible memory DC for a picture control of a dialog box. I am painting something in the memoryDC and I am using BitBlt() to copy from the MemoryDC to the DC of the pic control in a regular interval. I am seeing when I am calling Invalidate() for the dialog box, the memory DC is also getting erased, the old painting is lost and a subsequent BitBlt() paints from the beginning (of the graph what I am drawing in the Memory DC). If I dont call Invalidate() old painting is not lost- why its happening, does Invalidate() also erase memory DC.
3. Does BitBlt() not require a subsequent call to Invalidate() to display the data in the window?? (unlike SetPixel() or Lineto() which require a subsequent call to Invalidate() or WM_PAINT to display the data in the screen) !!
Please help
Sanjoy Sinharoy
Software Enggineer
HCL Technologies
India
|
|
|
|
|
1. Depends on whether or not the WS_CLIPCHILDREN style is set on the owner window. Look at WS_CLIPSIBLINGS too.
2. Try calling Invalidate with the erase parameter set to false.
3. You do not want to call Invalidate afterwards. You might want to consider doing the bitblt in the WM_PAINT (OnPaint) handler.
hope this helps.
|
|
|
|
|
Still answer to this uestion is not clear:
1. Does BitBlt() require a subsequent call to Invalidate() to display the data in the window?? Or it is NOT required??
2. Does Invalidate() also erase memory DC. I have tested Invalidate(true) and Invalidate(false) both erases the previous content of the display. If I dont call Invalidate() old painting is not erased.
Please help
Sanjoy Sinharoy
Software Enggineer
HCL Technologies
India
|
|
|
|
|
Is there a way to programmatically create a PDF file in
visual c++? I can print to paper and Im hoping that
if I change a few lines somewhere that I can print an
electronic copy in PDF somehow.
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
there are some free libraries you can get that will generate PDFs. You can google for "PDF Generation"
There also are some PDF projects here on codeproject. Search the articles.
|
|
|
|
|
DanYELL wrote: Is there a way to programmatically create a PDF file in
visual c++? I can print to paper and Im hoping that
if I change a few lines somewhere that I can print an
electronic copy in PDF somehow
What about this :-
http://www.codeproject.com/tools/Text2PDF.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Can someone provide me with a simple set of code to show heap memory allocation and deallocation?
Thank you very much
|
|
|
|
|
to allocate memory for an object of type OBJECT
<br />
OBJECT* obj = new OBJECT;<br />
to allocate memory for an array of objects of type OBJECT
<br />
OBJECT* obj = new OBJECT[array_size];<br />
to deallocate memory for an object of type OBJECT
<br />
delete obj;<br />
to deallocate memory for an array of objects of type OBJECT
<br />
delete [] obj;<br />
k_dehairy
|
|
|
|
|
the pink jedi wrote: Memory leak detection
Here what MSDN say about this :-
To detect a memory leak
Create a CMemoryState object and call the Checkpoint member function. This creates the first memory snapshot.
After your program performs its memory allocation and deallocation operations, create another CMemoryState object and call Checkpoint for that object. This gets a second snapshot of memory usage.
Create a third CMemoryState object and call its Difference member function, supplying as arguments the two previous CMemoryState objects. If there is a difference between the two memory states, the Difference function returns a nonzero value. This indicates that some memory blocks have not been deallocated.
This example shows what the code looks like:
// Declare the variables needed
#ifdef _DEBUG
CMemoryState oldMemState, newMemState, diffMemState;
oldMemState.Checkpoint();
#endif
// Do your memory allocations and deallocations.
CString s = "This is a frame variable";
// The next object is a heap object.
CPerson* p = new CPerson( "Smith", "Alan", "581-0215" );
#ifdef _DEBUG
newMemState.Checkpoint();
if( diffMemState.Difference( oldMemState, newMemState ) )
{
TRACE( "Memory leaked!\n" );
}
#endif
Notice that the memory-checking statements are bracketed by #ifdef _DEBUG / #endif blocks so that they are compiled only in Win32 Debug versions of your program.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi
Do anyone know how to get the size of any file in win32 system using APIs.
thanks
|
|
|
|
|
|
GetFileSize if you want to stick to Win32.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
vikramdelhi wrote: Do anyone know how to get the size of any file in win32 system using APIs.
if you tring to open Big file, try GetFileSizeEx
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hi
thanks a lot guys.
you all are really nice guys.
|
|
|
|
|
I want to prevent access to windows explorer when the user is using my app. Therefore, I have created a new desktop to run my app on. This way even though he can run explorer, he cannot practically use it. However, if from my app's open/save dialogs the user right-clicks and selects the explore option, he gets a new instance of explorer running on my desktop.
My question therefore is how do I prevent this? As far as my app goes, I can think of replacing the standard open/save and browse for folder dialogs with custom made ones. However, my app uses certain third-party resources for which I cannot do the same. Can I then somehow "hook" these dialog boxes, and prevent the user from running explorer.
Any other ideas on achieving my end result are welcome.
Thanks!
|
|
|
|
|
Krishnan V wrote: I want to prevent access to windows explorer when the user is using my app.
Why? What is it that you are ultimately trying to prevent access to?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
My application is used in critical applications. Therefore, normal users are not allowed to use anything outside of my app. Not even calculator! To get access to other applications, I might provide a password-protected option to them.
|
|
|
|
|
Hi ,
I m having problem updating my temporary Access databse , I get messages from socket every 1 sec , and I have to update Access tables . My application is a multithreaded , so there are times when multiple threads are trying to reand/ write same table.
Now my problem is I have tried to open Access table through CRecordset class , and when I debug it locally it run fine in multithread environment , like same table is opened by thread 1 and thread 2 is reading it , thread 3 is updating it etc.
But when I go live , I get errors like :
"Could not update; currently locked by user 'admin' on machine 'XXX"
how to catch this bug ? n how to fix it ?
plz can any body help ? If I use MS SQL SERVER can it resolve problem ?
Thx,
Zinc
HELLO
|
|
|
|
|
Hello
One way is to use a Mutex (and keep Access).
You could create a special function (or class) that handles all reads from, and writes to, the Access DB.
In that function (or class), use a Mutex.
Or, if reads are allowed at all times, just block the writes with a Mutex.
Kakan
|
|
|
|
|
|
Just as in that you can call LoadLibrary() on a DLL and then use GetProcAddress() to call a function within that DLL, is it possible to export a function from an exe? I know you can call LoadLibrary() and pass it an .exe and it will return a valid handle...
My end result is that I'd like to load an executable by another program (NOT run it) and determine what specific version it is...without using a version info resource within it. If I could set a function to export to return the version, that would be *perfect*.
Any other suggestions on getting at my end result would be appreciated.
Thanks,
|
|
|
|
|
Gunn317 wrote: ...is it possible to export a function from an exe?
Not that I am aware of.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
It IS possible! In searching the internet, I came across this article:
http://www.codeguru.com/Cpp/W-P/dll/article.php/c3649/
In trying to solve this problem yesterday, I had created a Win32 DLL using the VS.NET wizard with one function I was exporting. So, I just copy/pasted the code into a new header file which I included in one of my .exe source files, then linked. That was it and it worked.
I was able to call LoadLibrary() on the exe, then GetProcAddress() for the function. Here's the complete .h needed (VERSION_EXPORTS was defined in the project properties):
<br />
#ifdef VERSION_EXPORTS<br />
#define VERSION_API __declspec(dllexport)<br />
#else<br />
#define VERSION_API __declspec(dllimport)<br />
#endif<br />
<br />
VERSION_API int fnVersion(void)<br />
{<br />
return 6030;<br />
}<br />
|
|
|
|