|
Sorry i forgot to give some more details
The table of the database is tblDatabase and the colums are
token:: text
Spam::Number
Ham::Number
P::Number(with decimal points)
app::number
Thanks
|
|
|
|
|
|
Without actually knowing where it is crashing (and not being able to run it myself), here are the most likely places based on the code:
antonaras wrote: valField1 = pRecordset->Fields->GetItem("Token")->Value;
valField2 = pRecordset->Fields->GetItem("Spam")->Value.intVal;
valField3 = pRecordset->Fields->GetItem("Ham")->Value.intVal;
valField4 = pRecordset->Fields->GetItem("P")->Value.dblVal;
valField5 = pRecordset->Fields->GetItem("app")->Value.intVal;
printf("%d - %s\n",(LPCSTR)valField1,valField2,valField3,valField5);
If GetItem returns NULL for any of those items at any point in time, you will get an access violation. Also, if the types don't match up (that is, if the field is a double and you are checking the int value), you will get strange results that could blow up your stack in a weird place.
Additionally, the printf statement will blow up your stack the way it is written. When you have 2 arguments in the printf string, you should only have 2 variables to match them (you have 2 in the string and 4 trying to match them).
antonaras wrote: m_pConn->Close();
You didn't close the recordset, so at this point, the connection is being closed. Now, when the Recordset smart pointer goes out of scope, it will attempt to close, but it will no longer have a connection. Try adding a pRecordset->Close(); call prior to the connection's close call.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
-- modified at 15:21 Thursday 1st June, 2006
|
|
|
|
|
antonaras wrote: printf("%d - %s\n",(LPCSTR)valField1,valField2,valField3,valField5);
This should be:
printf("%d - %s\n", valField2, (LPCSTR) valField1);
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
I was handed down a big windows base project at work that requires some attention. We have been experiencing some random crashes and bugs in the field. I’m working on debugging this issues but I need a little help. We have limited time to debug all issues so I was wondering if there are any commercially available tools (I’m currently looking at SOFTICE) that I could use to monitor the executable and record system parameters when the system is in the field. I need to pin point the root cause of the problems. I’m trying to get a sense of what’s going on in the field that’s causing the random behavior of the executable.
Thank you
|
|
|
|
|
|
this really diserves a 5
ooh and don't take the Express version because that one is for free
codito ergo sum
|
|
|
|
|
How is it that correlating the user dump file data with the PDB and source of your application is not sufficient to track this down? Is it memory corruption over time that is suspected? Then make a build that allows periodic memory validation to be performed and dump anything suspicious.
Otherwise, a flat out crash can be diagnosed directly using the user dump file and the Microsoft Debugging Tools. What did you expect the 'good commecrial debugger' to do for you?
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
I’m looking for more of a system level debugger. What I was told by a coworker is that there is software that works with you code to track bugs and system information (which was something that he read a long time ago). The "software" goes in the background of the source code and helps to log the parameters that lead up to the crash or the bug. I'm using visual studio when I run the code in debug mode, but I need to know what happens with the system in the field. I will be implementing debugging functionalities but it's going to take some time catch everything and I'm looking for a way to speed this up.
Thank you for all the responses
|
|
|
|
|
The Visual Studio debugger is by far the best debugger for Windows development. There are entire books on a portion of the features it has. If you need something specific that the VS debugger doesn't do (or rather, doesn't give you all the information you would like), check out Compuware. They have some very powerful stuff to help debug a vast array of common issues (e.g. Bounds Checking).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
I believe Numega Boundschecker does something similar. I used it once upon a time to find some memory leaks and it seemed to work ok, but that was about 7 years ago now. I think boundschecker's still around though in a new form.
When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!!
|
|
|
|
|
As far as I can tell this AppSight stuff is quite different from Boundschecker. The idea is that you instrument an application out in the field - essentially provide it with a black box. Then the customer sends a file back to the developers. They open it in an IDE and you can step backwards and forwards through the code to see what's going on. It's geared towards the common scenario of "it works on the developers' machines but not the customers."
Kevin
|
|
|
|
|
Hi I hope I'm in the right group here.
I am trying to develop an ActiveX control but whenever I compile a debug version of it I am unable to include it in another application. It always gives an error claiming an exception has occurred in ctlnownd.cpp line 443(if I remember correctly). The release version of this control works fine.
I am using VC++ 6 with I think the latest patches although I haven't checked for a while.
Any ideas why this happens and if it can be corrected.
Many thanks
Andrew
|
|
|
|
|
Can you post some code around the point where your program crashes ?
It is also very usefull to use your debugger. Watch the callstack to see which of your function causes the crash.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
My program doesn't really crash. It compiles fine, works fine in the ActiveX Control Test Container but whenever I try place it in another application , be that a Powerpoint slide another VC++ MFC dialog application then it causes an exception in ctlnownd.cpp when you try to place the object in the application.
I have kind of read on the web that this is a known problem but no one seems to say whether there is a solution to it. Without being able to include the debug version is another app it is proving very hard to debug it.
Thanks for any advice you may be able to give.
Andrew
|
|
|
|
|
hi there
somebody tell me pleease, how to play a wave sound when start some application or after performing some function.
something like start windows sound as example or icq program.
thanks in advance.
|
|
|
|
|
see this article.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
How about sndPlaySound() or PlaySound() ?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
So I'm going through the source code for the Log4CPlus logging library and found this snippet:
#define LOG4CPLUS_DEBUG(logger, logEvent) \
do { \
if(logger.isEnabledFor(log4cplus::DEBUG_LOG_LEVEL)) { \
log4cplus::tostringstream _log4cplus_buf; \
_log4cplus_buf << logEvent; \
logger.forcedLog(log4cplus::DEBUG_LOG_LEVEL, _log4cplus_buf.str(), __FILE__, __LINE__); \
} \
} while(0);
This of course logs a given string to the active logging class. The question is why have they wrapped all that in a do-while loop?
If you look at the loop, it will only be called once (while(0)). Is this some kind of preventitive measure to ensure that the compiler or optimiser does not strip the macro code out?
I Dream of Absolute Zero
|
|
|
|
|
|
Ahhh! Thanks.
I Dream of Absolute Zero
|
|
|
|
|
The reason given in that article is actually pretty poor. Yes, it forces the programmer to use a trailing semi-colon, but that isn't necessary (mostly, they do that simply for looks). The real reason for enclosing it in a do-while loop is to prevent naming conflicts.
For example, lets say you have the following macro:
#define SWAP_INT(a, b) \<br />
int c = a; \<br />
a = b; \<br />
b = c;
Now, your code looks something like the following:
void main()<br />
{<br />
int a = 1, b = 2, c = 0;<br />
SWAP_INT(a, b);
}
This creates a hard to find compiler-error that will annoy you (and anyone else trying to use that macro with a variable named 'c').
To prevent this, you could use the scoping operator:
#define SWAP_INT(a, b) \<br />
{ \<br />
int c = a; \<br />
a = b; \<br />
b = c; \<br />
}
However, some older C++ compilers do not treat this correctly (or even handle it at all. Thus, you can create a single loop do-while to handle the scoping:
#define SWAP_INT(a, b) \<br />
do { \<br />
int c = a; \<br />
a = b; \<br />
b = c; \<br />
} while (0);
The trailing ; is purely optional. If you leave it off, you force the programmer to place it themselves (thus treating it like a function call). Putting it there doesn't hurt anything though.
As a side note, declaring it the way they did (as a macro) is poor programming practice. It really should have been declared as a function. If the user passes an int as the "logger", they will get some weird compiler error messages dealing with types and unless they search through the code to find the macro defintion, will have no idea why it is happening.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
-- modified at 11:53 Thursday 1st June, 2006
|
|
|
|
|
Very clearly explained. Thank you.
You got my 5.
I Dream of Absolute Zero
|
|
|
|
|
An excellent explaination! However, I will offer one more use of the do/while(0) block. I have seen it used as a way to provide goto -like functionality without actually using the word goto .
For example, if you needed to jump out of the middle of the block, simply executing a break will take you to the bottom of the block, simulating a goto to a label at the end of the block.
It was a bit confusing the first time I saw code that used the do/while(0) like that...
[Edit: Note, I do not do this myself, and would use (and have used) used a goto in place of something like that...]
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|