|
Hi all,
I'm using Edit() and Update() functions to update the fields in the table. However, at particular (always) record, I got error exception which can't catch with CDBException or CException. So I used catch(...) to catch any exception. Then used sqlcomman to update the field. That particular record, let's say recnum=600,
exception got thrown, caught it by using catch(...), the field2 of recnum=600 got updated executing sql command "UPDATE ... SET". But got exception at the next following record,which is in this example, recnum=601, and got another CDBException after calling SQL command, . Error is saying "connection to DB got lost".
Why??
Why can't always at some particular record cant' update and throwing exception that can't catch with neither CDBException nor CException.
Why after that particular record get updated with SQL command, the next record can't update by using Edit() and Update() or ExecuteSQL()?
my code looks like this
<br />
while(!rs.IsEOF())<br />
{<br />
if(recnum==600 || recnum==953 )
rs.MoveNext();<br />
rs.Edit();<br />
rs.field2 = newdata;<br />
rs.Update();<br />
<br />
}<br />
catch(...)
{<br />
CString qstr;<br />
qstr.Format("Update %s set field2=%d where recnum=%d",tablename,newdata,recnum);<br />
rs.m_pDatabase->ExecuteSQL(qstr);<br />
}<br />
<br />
|
|
|
|
|
Does your code fail to update any record, or just the two following rows 600 and 953?
pnpfriend wrote: Error is saying "connection to DB got lost".
Are you sure this is the exact text of the message?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Just at that two rows, David.
I try to call the same function that Update the recordset using CRecordset::Edit() and CRecordset::Update() serveral time to see. whenever it reachs to those rows, the exception got thrown and couldnt' catch with CDBException or CException.
If I skip using row number 600, like
if(rownum == 600)
rs.MoveNext();
I got stack at row number 953 and then.. if I skip that row using same way as 600 (if statement), I got error again at another rows.. all the way down somewhere.. it is like keep comming up once in awhile. I dont' get error at every single row but certain rows.
So I try to catch error with catch(...) and able to use sql command to update at first row which is rownum=600. but the following record which was able to update before using if statement to skip rownum=600, can't update any way anymore.. either using CRecordset::Update() or ExecuteSQL().
|
|
|
|
|
My cod is fail to update at those two records.
The error message was saying "Lost Connection to MySQL server during query."
after skipping that two records.
|
|
|
|
|
Does this help?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
I've been playing with different programming languages for the last few months. Mainly from books, websites etc. To be frank all of this is VERY dry (I know, I know - its programming what did I expect :P). If I see "Hello World" again I think I'll snap. Its all basic - understandably - but for me (at this point) its TOO basic. I guess I would consider myself an intermediate programmer.
The issue with being an intermediate programmer - one that cannot yet create a whole program - is that there is lack of direction. I will be taking a class on VB.Net this semester which SHOULD clear up a lot of my questions / issues.
What I am trying to find is a simple game and its code. As far as I know Tetris is one of the most basic games (as far as programming goes) and would be a great study. I'm having issues trying to find a copy with code attached.
I have a copy of Visual Studio 6. If anyone could point me in the direction of some code for Tetris - or a simple game that I can delve into please let me know. If it is geared toward learning to program that'd be a huge bonus!
Thanks!!
Dan
-- modified at 10:53 Wednesday 28th December, 2005
|
|
|
|
|
dbough wrote: I will be taking a class on VB.Net this semester which SHOULD clear up a lot of my questions / issues.
Or create a ton more.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
A game of tetris is nothing but implementation of a logic in C/C++, so if you know the logic of Tetris which is quite easy, you should not have problem implementing it.
-Prakash
|
|
|
|
|
Hello,
The only way that you'll learn to write a complete program is to do it yourself. The things that you'll learn from sample code is almost nothing more than how to use it.
Programming is not as most people think: writing code, but programming is way more than that: finding and designing solutions to a given problem. Writing code is just one way to implement it and this too is a skill that is only learned by doing.
So the best way for you is a simple problem that you have (this can be tetris or some administrative problem) and try to make a sound solution for it. Than implement the solution in some programming language.
This is how I learned to make programs.
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hi Bob,
Very good answer, that's how a learned too! You find some thing that you wish to write a program for, then figure out how to do it, one piece at a time, as you write it.
P.S. You once told me you where taking classes, well I am now going back to. I need those little pieces of paper.
INTP
Every thing is relative...
|
|
|
|
|
Hello John,
Thank you!
John R. Shaw wrote: P.S. You once told me you where taking classes, well I am now going back to. I need those little pieces of paper.
If all goes well, then I'll get my paper in 6 months. After that, I'll (happily) start working.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
You might try looking here[^] on SourceForge.
Software Zen: delete this; // <a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" rel="nofollow">Fold With Us!</a>[<a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" target="_blank" rel="nofollow" title="New Window">^</a>]
|
|
|
|
|
Thank you all for your replies. As I ahve said I am a (self proclaimed) intermediate programmer - perhaps that is overtating my skill - its hard to judge my abilities when I have nothing to compare them too.
By looking at the code for a program that I am familiar with (ie Tetris) I can pick apart things I know and find things I don't know. By finding code I am not familiar with, it is my belief, I can gain a direction and figure out what I need to learn to further my understanding of programming.
I can read all the books I want, but theory is just that - theory. Without practice (again, I'm not 100% familiar with all aspects of programming) or some 'reverese engineering' finding a direction to lead myself down can be frustrating.
If I could define a problem and then try to find a solution to get an answer I would - I think my biggest issue is not being familiar with all the tools I have at my disposal to complete the job.
|
|
|
|
|
Here is an idea for you!
Get a copy of "The C++ Programming Language" by Bjarne Stroustrup. Recreate the code for the desktop calculator, by typing it in by hand (important). Once you have it working, figure out how to get it to work with a (Windows) GUI front end (may require some rewriting).
I guarantee, by the time you have accomplished that, you will know a lot more about programming.
I have an algibraic equation parser function that I wrote in C, 18-19 years ago (that still works today). I started with some code in a book, I rewote it, modified it completely, and expanded its capabilities. Then I created a caculator and a program for graphing algibraic equations. Well actualy, in those days, I had to create a DOS windowing interface first, since my goal was to write an equation graphing program to start with.
When you are writing code for your self it can be fun, it only becomes dry (some times) when you have to do it for someone else. I stopped enjoying it as much when I could look at the problem and know the answer before I touched a keyboard (what fun is that?), after that it was just typing, and typing, and typing. To bad the computer could not just read my mind.;)
As for the understanding what tools you have and how to use them, first understand the language at the console level. The majority of the tools available with VC6 are to simplify creating GUI applications and are MS Windows specific.
Well that's enough, good luck.
INTP
Every thing is relative...
|
|
|
|
|
I have loaded image using GDI funcs and ZOOMING in and out using stretchblt funcn with memory as source and window screen as destination. while zooming in i am invalidating the screen area with third param set as false and hence able to achieve flicker free image but how to do low flicker (if possible no flicker ) for zoom out.
also please tell me if i can directly write on to the vdu buffer and freeze the client area until the write on buffer is complete
Thankyou
nothing is illegal until you are caught
|
|
|
|
|
There are articles at CP on flicker free drawing, and it is probably in the FAQ as well. Essentialy you need to override OnEraseBkgnd() so that it does not earase the background (causing flicker), then do all the drawing (including background if any) in the OnDraw() function. It actualy can be a little more complicated than that, so look at any code the displays bitmaps of thumb nails or allows you to edit an image (See CP articles).
INTP
Every thing is relative...
|
|
|
|
|
how to maintain the logfile of any file being accessed (opened,modified,renamed,deleted) in any drive(i mean the whole system). the application should be developed in MFC. please help me and reply as soon as possible.
RabiaAslam
|
|
|
|
|
uh. What have you written? I have read it in many ways, it simply is not making sense.
Please refine your question if you would need someone to respond quickly.
Vipin - MVP
|
|
|
|
|
See here for how file monitoring is done.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Call FindFirstChangeNotification for each drive on the system, then do a WaitForMultipleObjects on the list of handles returned. See the docs for FindFirstChangeNotification.
onwards and upwards...
|
|
|
|
|
I've got to improve some code with memory leaks but how to identify their location in a source file, I've got only this output after program terminates and not a hint for a source code:
Detected memory leaks!
Dumping objects ->
{715} normal block at 0x00EAE450, 800 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
{541} normal block at 0x0033FBC8, 4 bytes long.
Data: <0 > 30 00 00 00
{540} normal block at 0x0033FA10, 5 bytes long.
Data: <000 > 30 30 30 00 CD
{279} normal block at 0x0033F8A0, 8 bytes long.
Data: < > 00 00 00 00 00 00 00 00
{273} normal block at 0x0033F6C0, 8 bytes long.
Data: < > 16 1E 00 00 EA 1D 00 00
{272} normal block at 0x0033F680, 2 bytes long.
Data: <01> 30 31
{268} normal block at 0x0033ED48, 4 bytes long.
Data: < > 00 00 00 00
{266} normal block at 0x0033EE10, 2 bytes long.
Data: <1 > 31 00
{264} normal block at 0x0033ED88, 2 bytes long.
Data: <0 > 30 00
{232} normal block at 0x0033E3A0, 5 bytes long.
Data: < > 00 00 00 00 00
Object dump complete.
9ine
|
|
|
|
|
I recommend you use the following FREE leak detecting code:
http://code.axter.com/leaktracker.h[^]
You can download the assoicated DLL file via following link:
http://code.axter.com/leaktracker.zip[^]
This program will output the leak location (source-file-name, line-number). It will also give the Function name if your compiler supports it (like VC++7.x & GNU 3.x)
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
-- modified at 8:28 Wednesday 28th December, 2005
|
|
|
|
|
this does not work, first I just added leaktracker.h to the project, lib and dll to windows system dir and run the project from VS 2003. Then closed the project and get standart memory leak in VS output window but there was no file C:\zz_David_Maisonave_DefaultLeakTrackerLogFile.log after termination. Then I added #include to the .cpp file that created additional mem leak on purpose for testing and the project doesnt want to be compiled:
Compiling...
sGenDlg.cpp
**************************************************************************************
Note: Including leaktracker implementation... DO NOT USE THIS BUILD FOR PRODUCTION!!!
**************************************************************************************
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2433: 'new' : 'inline' not permitted on data declarations
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2365: 'new' : redefinition; previous definition was a 'member function'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2078: too many initializers
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2440: 'initializing' : cannot convert from 'int' to 'void *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2143: syntax error : missing ';' before '('
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2226: syntax error : unexpected type 'size_t'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2059: syntax error : ')'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2447: '{' : missing function header (old-style formal list?)
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2433: 'new' : 'inline' not permitted on data declarations
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2365: 'new' : redefinition; previous definition was a 'member function'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2078: too many initializers
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2440: 'initializing' : cannot convert from 'int' to 'void *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2143: syntax error : missing ';' before '['
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C3409: empty attribute block is not allowed
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : warning C4518: 'char ' : storage-class or type specifier(s) unexpected here; ignored
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : warning C4518: 'char ' : storage-class or type specifier(s) unexpected here; ignored
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(188) : error C2447: '{' : missing function header (old-style formal list?)
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(264) : warning C4005: 'new' : macro redefinition
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(10) : see previous definition of 'new'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(143) : error C2665: 'operator new[]' : none of the 5 overloads can convert parameter 2 from type 'const char [91]'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\crtdbg.h(669): could be 'void *operator new[](size_t,int,const char *,int)'
while trying to match the argument list '(size_t, const char [91], long, const char [29])'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(176) : warning C4244: '*=' : conversion from 'double' to 'int', possible loss of data
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(188) : warning C4244: '*=' : conversion from 'double' to 'int', possible loss of data
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(225) : error C2665: 'operator new' : none of the 5 overloads can convert parameter 2 from type 'const char [91]'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\crtdbg.h(662): could be 'void *operator new(size_t,int,const char *,int)'
while trying to match the argument list '(size_t, const char [91], long, const char [29])'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(231) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(234) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(237) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(259) : warning C4018: '<' : signed/unsigned mismatch
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(261) : warning C4018: '<' : signed/unsigned mismatch
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\sGenDlg.cpp(290) : error C2665: 'operator new[]' : none of the 5 overloads can convert parameter 2 from type 'const char [91]'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\crtdbg.h(669): could be 'void *operator new[](size_t,int,const char *,int)'
while trying to match the argument list '(size_t, const char [91], long, const char [29])'
9ine
|
|
|
|
|
In your sGenDlg.cpp file, the leaktracker.h must be the LAST included header.
If you include it before any other headers, you'll get compile errors, or runtime errors.
This program was originally developed using VS 2003, and then ported to GNU, Borland, and VC++ 6.0.
So it should definitely work on VS 2003.
FYI:
If it doesn't produce a log file, then either it was not compiled in DEBUG moder, or there were no memory leaks.
Since you didn't get compile errors the first time, I must assume it was not compiled in DEBUG mode.
If you don't see the following message when you compile, then the leak tracking code is not getting included.
**************************************************************************************
Note: Including leaktracker implementation... DO NOT USE THIS BUILD FOR PRODUCTION!!!
**************************************************************************************
If you wish to include the leak tracking code in the release version of your program you could do so by defining the following macro before including the header:
#define DEBUG_VERSION_
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
-- modified at 10:59 Wednesday 28th December, 2005
|
|
|
|
|
No I'm not inclined to use it in release version, I'm sure I've got debug compiler option and I included it as you said:
#include "stdafx.h"
#include "sGen.h"
#include "sGenDlg.h"
#include ".\sgendlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include "Lib\lib.h"
#include "Lib\quantize.h"
#include "LibST\scomplexity.h"
// CsGenDlg dialog
#include "leaktracker.h"
CsGenDlg::CsGenDlg(CWnd* pParent /*=NULL*/)
: CDialog(CsGenDlg::IDD, pParent)
, m_freq(10)
, m_sr(128)
, m_len(30), data(0)
, m_asize(2)
, qt(0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
All the same compiler errors again? it doesnt want to be compiled, I use VS2003.
As for the first time I did not include leaktracker.h in any cpp file at all, which is not proper as I've read from its manual that it should be included at least in one file, and I ran it in debug mode (which we select from proj settings->config manager->active solution config), and to test it I used on purpose allocation of memory with new command without deleting it.
What is your suggestions?
look at the errors again:
Compiling...
sGenDlg.cpp
**************************************************************************************
Note: Including leaktracker implementation... DO NOT USE THIS BUILD FOR PRODUCTION!!!
**************************************************************************************
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2433: 'new' : 'inline' not permitted on data declarations
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2365: 'new' : redefinition; previous definition was a 'member function'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2078: too many initializers
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2440: 'initializing' : cannot convert from 'int' to 'void *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2143: syntax error : missing ';' before '('
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2226: syntax error : unexpected type 'size_t'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2059: syntax error : ')'
c:\Documents and Settings\yc274\My Documents\Visual Studio Projects\COMPL\sGen\leaktracker.h(184) : error C2143: syntax error : missing ';' before '{'
and so on...
9ine
|
|
|
|
|