Newbie -> it works in XP but not in win98 =(

Hello there,

I'm new to programming in C++ but I do have some Java experience. Now I have written an application under Microsoft Visual C++ 6.0 and when I compile it, it has 0 warnings and 0 errors also linking goes well. But when I run the executable under win98 (under which I build) it crashes Under XP it works fine...... :-s But I need to run the program under 98......
It uses the mysql++ lib file which I have obtained from the mysql site.
It connects with the database and scans if there are new entry and if so it prints these entries
The computer under which I compile is an win98 system with a P100 processor and 24 MB memory. The XP machines are ofcourse faster....
Is the memory a problem here???
Can anybody help me on the road again ????
If it is a programming bug please send me the source like it should work according 2 U

I'll be thankfull !!!

Greetings

Ronald

Here's the listing:

#include
#include
#include
#include


class Probe
{
private:
int ID;
public:
SetID(int thisID);
ShowCurrenID();
Exist();
ToScreen();
ToPrinter();
};

Probe::SetID(int thisID)
{
ID=thisID;
}

Probe::ShowCurrenID()
{
cout << ID << endl;
}

Probe::Exist()
{
cchar *db="MyDB";
cchar *host="10.10.X.X";
cchar *user="*******";
cchar *passwd="********";
int check;
try {
Connection con(db, host, user, passwd);
Query query = con.query();
query << "select * from bestellingen where ID=" << ID;
Result res = query.store();
//query.preview();
Row row;

Result::iterator i;

for (i = res.begin(); i != res.end(); i++) {
row = *i;
check=row[0];
}
if (check!=ID) {return false;} else {return true;}

}catch (BadQuery er){ // handle any connection
// or query errors that may come up
cerr << "Error: " << er.error << endl;
return false;

} catch (BadConversion er) {
// we still need to cache bad conversions incase something goes
// wrong when the data is converted into stock
cerr << "Error: Tried to convert "" << er.data << "" to a ""
<< er.type_name << ""." << endl;
return false;
}
}

Probe::ToScreen()
{
cchar *db="MyDB";
cchar *host="10.10.X.X";
cchar *user="******";
cchar *passwd="********";
try {
Connection con(db, host, user, passwd);
Query query = con.query();
query << "select * from bestellingen where ID=" << ID;
Result res = query.store();
Row row;

Result::iterator i;

for (i = res.begin(); i != res.end(); i++) {
row = *i;
cout.setf(ios::left);
cout << "
Volg#: " << row[0] << "
Tijd: " << row[1] << "
Datum: " << row[1] << "

Naam: " << row[5] << " " << row[6] << "
Plaats: " << row[7] << "

Bestelling:
" << row[3] << "
totaal: " << row[4] << "
-----------------------------------------------------"<< endl;
}

}catch (BadQuery er){ // handle any connection
// or query errors that may come up
cerr << "Error: " << er.error << endl;
return false;

} catch (BadConversion er) {
// we still need to cache bad conversions incase something goes
// wrong when the data is converted into stock
cerr << "Error: Tried to convert "" << er.data << "" to a ""
<< er.type_name << ""." << endl;
return false;
}
return 0;
}

Probe::ToPrinter()
{
cchar *db="MyDB";
cchar *host="10.10.X.X";
cchar *user="*******";
cchar *passwd="*******";
try {
Connection con(db, host, user, passwd);
Query query = con.query();
query << "select * from bestellingen where ID=" << ID;
Result res = query.store();
Row row;

Result::iterator i;

for (i = res.begin(); i != res.end(); i++) {
row = *i;
FILE *stream;
stream = fopen("PRN", "w");
fprintf(stream, "



");
fprintf(stream, "Order#: ");
fprintf(stream, row[0]);
fprintf(stream, "

Time: ");
fprintf(stream, row[1]);
fprintf(stream, "
Date: ");
fprintf(stream, row[2]);
fprintf(stream, "


Name: ");
fprintf(stream, row[5]);
fprintf(stream, " ");
fprintf(stream, row[6]);
fprintf(stream, "

Seat: ");
fprintf(stream, row[7]);
fprintf(stream, "





Order:

");
fprintf(stream, row[3]);
fprintf(stream, "




Total: EUR. ");
fprintf(stream, row[4]);
fprintf(stream, "f");
fclose(stream);
}

}catch (BadQuery er){ // handle any connection
// or query errors that may come up
cerr << "Error: " << er.error << endl;
return false;

} catch (BadConversion er) {
// we still need to cache bad conversions incase something goes
// wrong when the data is converted into stock
cerr << "Error: Tried to convert "" << er.data << "" to a ""
<< er.type_name << ""." << endl;
return false;
}
return 0;
}

int main(int argc, char * argv[]) {

int slaap=40000; // Aantal seconden voor volgende probe

int user=atoi(argv[1]); //zet een command line getal in user
Probe prober;


int a=1;
int b;
if (user==0) {b=1;} else {b=user;}
while(a==1)
{
prober.SetID(b);
if(prober.Exist())
{
prober.ToScreen();
//prober.ToPrinter();
b++;
}
Sleep(slaap);
}
return 0;

}


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories