Extract data from database
-
dreamerzz wrote: so using CArray is the only solution... No, of course not. It's just one of many implementations. From what information you've provided, it sounds like you simply need to store the numbers in a text file. Then you could process them with something like:
CStdioFile file("", CFile::modeRead);
CString strLine;
int nSum = 0,
nLineCount = 0;while (file.ReadString(strLine) != FALSE)
{
nSum += atoi(strLine);
nLineCount++;
}TRACE("The sum is %d\nThe average is %f\n", nSum, (double) nSum / nLineCount);
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
DAMAGE: after Client block (#74) at 0x00432C50 i have tried a lot of other methods, when i compile it, there is no error but when i wan to build, it show me this dialog box
dreamerzz wrote: when i compile it, there is no error but when i wan to build, it show me this dialog box Are you differentiating between a compile and a build? If so, I can only assume that you mean build to be both a compile and a link. Yes?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
dreamerzz wrote: when i compile it, there is no error but when i wan to build, it show me this dialog box Are you differentiating between a compile and a build? If so, I can only assume that you mean build to be both a compile and a link. Yes?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Yes, using the
CDatabase
andCRecordset
classes.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
sorry for the confusion. There is a build and execute. When i build, there is no error and no warning. but when i execute, it show me the dialog box
Have you single-stepped through the code to see which is the offending statement? Up until you know the statement in question, we can't be of much help.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Yes, using the
CDatabase
andCRecordset
classes.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Yes there is. Using the
new
operator. At run-time, find out the number of records, and then allocate an array long enough to hold values you want to retrieve. For example, assuming that you've 50 records, the code will look like this:LONG lRecCount = 50; // you won't hardcode this, but get it at run-time from database
double *pdblValues = new double[lRecCount + 1];
for(LONG i = 0; i < lRecCount; i++)
pdblValues[i] = collect value from the field here;One more thing, don't forget to
delete[] pdblValue
after you are finished with it. Hope that helps, Gurmeet
BTW, can Google help me search my lost pajamas?
My Articles: HTML Reader C++ Class Library, Numeric Edit Control
-
Yes there is. Using the
new
operator. At run-time, find out the number of records, and then allocate an array long enough to hold values you want to retrieve. For example, assuming that you've 50 records, the code will look like this:LONG lRecCount = 50; // you won't hardcode this, but get it at run-time from database
double *pdblValues = new double[lRecCount + 1];
for(LONG i = 0; i < lRecCount; i++)
pdblValues[i] = collect value from the field here;One more thing, don't forget to
delete[] pdblValue
after you are finished with it. Hope that helps, Gurmeet
BTW, can Google help me search my lost pajamas?
My Articles: HTML Reader C++ Class Library, Numeric Edit Control
Gurmeet S. Kochar wrote: double *pdblValues = new double[lRecCount + 1]; Why the extra one?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
ok. I think this is also the very last ans i would get. Although i don't really know how to go abt it. but still thanks for all the help that u have given.. thanks.
dreamerzz wrote: Although i don't really know how to go abt it In one of my earlier posts, I provided a link to a "how to" article. Once you go through those steps, not just glancing over them, you'll have a working example. Here are some others: http://www.codeproject.com/database/#ODBC http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vctutor98/html/\_gs\_creating\_a\_new\_database\_application.asp http://msdn.microsoft.com/library/en-us/vctutor98/html/\_gs\_about\_step\_1.asp?frame=true
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Hi, I have tried out the coding that you have given me. but i dun seems to get the results also.. Anyway, thanks for the help given.
Can you please provide us with some code of how you are doing this. It may be that you are doing something wrong in your code. Gurmeet
BTW, can Google help me search my lost pajamas?
My Articles: HTML Reader C++ Class Library, Numeric Edit Control