|
Thanks for your help manoj, very thanks....
And thanks for the code, I'll test it right now
|
|
|
|
|
Hi there,
Please specify how to decide whether to go for return codes or exception handling.
When is exception handling preferred over returning a specific error code.
Thanks in advance,
Raja Pratap
|
|
|
|
|
IMHO you need a decision between throwing an exception or returning a specific error code.
If it is as above stated, then I think:
(1) If it's your own application (entirely developed by you) then you can (almost) safely rely on return error codes, since you know that calling methods must always check the return values.
(2) If your're working in team then throw, throw, throw: never trust your mates coding neatness!!!
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thank you for your response Pillani.
But still I'm not clear, why return codes are not suitable when we work as team.
|
|
|
|
|
Hi,
I think it is because you can not be totally sure about what the others will do. If they get an assertion, they have to solve something, if they have a return code, they can make nothing about or even don't realize about the error. And then error will be cumulating themselves until it would be too difficult to correct the program.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Raj Prathap wrote: But still I'm not clear, why return codes are not suitable when we work as team.
Well, suppose you have a method returning failure. If the caller doesn't check the return value and continues execution, maybe some disaster is along the way. On the other hand, throwing an exception, you force the caller to handle it or, anyway, the execution will be stopped.
Now, if the caller is a member of you team (and not yourself) then there is a chance that importance of return value is underestimated.
Hope that helps
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thanks Pallini, That answers my question.
|
|
|
|
|
Hello everybody,
is it possible to supress also the flickering with Groupboxes?
I get it to size my views without textbox & label flickering, but the groupboxes still
fickers.
Big thanks
|
|
|
|
|
I want to insert a binary file, say "tt.bin", into a field (image type) of SQL database, I wrote a program as follows
C++, VS2003, ADO, input file: tt.bin,database: moldb,
Create table moltbl (id INT, mol IMAGE);
But I didn't get nothing in the output file: new.bin
where am I wrong, please? thanks very much!
// BLOB.cpp
#import "c:/Program Files/Common Files/System/ADO/msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
::CoInitialize(NULL);
_RecordsetPtr m_pRecordset("ADODB.Recordset");
_ConnectionPtr m_pConnection("ADODB.Connection");
_bstr_t bstrSQL("select * from moltbl");
ifstream moldata;
moldata.open("tt.bin", ios::in|ios::binary);
ofstream newdata;
newdata.open("new.bin", ios::out|ios::binary);
char buffer[10240];
char *pBuf = buffer;
long nFileLen = 0;
if (!moldata.fail() && !moldata.eof())
moldata.read(buffer,10240);
nFileLen = moldata.gcount();
VARIANT varBLOB;
SAFEARRAY *psa;
SAFEARRAYBOUND rgsabound[1];
int index = 0;
_bstr_t strConnect = "Provider=SQLOLEDB; Server=ELSE-HP;"
"Database=moldb; uid=sa; pwd=sa";
m_pConnection->Open(strConnect, "", "", adModeUnknown);
if(m_pConnection == NULL)
cerr<<"Load data ERROR!\n";
HRESULT hr = m_pRecordset->Open("SELECT * FROM moltbl",
_variant_t((IDispatch *)m_pConnection,true),
adOpenDynamic,
adLockPessimistic,adCmdText);
m_pRecordset->AddNew();
m_pRecordset->PutCollect("id",_variant_t(index++));
if(pBuf)
{
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = nFileLen;
psa = SafeArrayCreate(VT_UI1, 1, rgsabound);
for (long i = 0; i < (long)nFileLen; i++)
SafeArrayPutElement (psa, &i, pBuf++);
varBLOB.vt = VT_ARRAY | VT_UI1;
varBLOB.parray = psa;
m_pRecordset->GetFields()->GetItem("mol")->AppendChunk(varBLOB);
}
m_pRecordset->Update();
long lDataSize =_pRecordset->GetFields()->GetItem("mol")->ActualSize;
ifstream newfile;
newfile.open("new.bin", ios::out| ios::binary);
if(lDataSize > 0)
{
_variant_t varBLOB;
varBLOB = m_pRecordset->GetFields()->GetItem("mol")->GetChunk(lDataSize);
if(varBLOB.vt == (VT_ARRAY | VT_UI1))
{
SafeArrayAccessData(varBLOB.parray,(void **)&pBuf);
newdata.write(pBuf, lDataSize);
SafeArrayUnaccessData (varBLOB.parray);
}
}
moldata.close();
newdata.close();
return 0;
}
Hi, there. Need your help!
|
|
|
|
|
Have you bothered to step through your code using the debugger to see where the problem lies?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for suggestions
I've stepped into it, and find something seems wrong at
if(pBuf)
{
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = nFileLen;
psa = SafeArrayCreate(VT_UI1, 1, rgsabound);
for (long i = 0; i < nFileLen; i++)
SafeArrayPutElement (psa, &i, pBuf++);
varBLOB.vt = VT_ARRAY | VT_UI1;
varBLOB.parray = psa;
m_pRecordset->GetFields()->GetItem("mol")->AppendChunk(varBLOB);
}
becouse when i did as follow:
m_pRecordset->Update();
long lDataSize = m_pRecordset->GetFields()->GetItem("mol")->ActualSize;
I find that the value of lDataSize is alwayse -1
do you know the reason, please?
thanks a lot
regards.
Li
Hi, there.
|
|
|
|
|
I've also posted my question in the ADO forum,
http://www.codeproject.com/script/comments/forums.asp?forumid=1725&select=2047403&msg=2047403
so, please go there if you want to help me, thanks.
best regards
Hi, there.
|
|
|
|
|
hi,
How can i read data from an excel file and write data to the cells, by just specifying the column name? how to open and close the excel file?
Thanks in advance.
SYAMLAL
|
|
|
|
|
Search for Excel Automation.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
|
Hello,
In VC++6 you can go to project settings and in th LINK tab, set the names for the object/library modules.
How can this be done in VC++8?
Thank you in advance.
|
|
|
|
|
Project -> Properties then expand Configuration Properties then Linker then click on Input. Add your libraries to Additional Dependencies
Judy
|
|
|
|
|
Go into project properties, "Linker", "Input" and put them in "Additional Depedencies".
|
|
|
|
|
hai,
i want to store the userdefined values in a dialog based applications & i want to get that values when we run the program next time.
|
|
|
|
|
You can save the data to a file and then load the file when your program start the next time.
|
|
|
|
|
If you are using MFC, then have also a look at Serialization [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
jannathali wrote: userdefined values
What kind of values is this about?
Perhaps you should consider using the registry if this is about application settings.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
|
Problem- When I click on the empty space after any item or after all items then the current item selection goes away and I have no way to highlight previous item. (Though I have pervious selected item index).
This is beacuse when item is selected MFC gives us two messages
1. Pervious Item Deselected.
2. Current item Selected.
But when we click on empty area then
1) it gives message - Item Deselected ...
and there is no other message again ....
So we cant track whether you get 1 or 2 message from MFC....
This is all my perception about CListCtrl behaviour
Does any one have a way to this problem????
Thanks in Advance
AmolM
|
|
|
|