|
From doco on DeleteDC
"An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC."
If you use CreateCompatibleDC of CreateDC you need to delete it when done by calling DeleteDC .
Calling ReleaseDC doesn't actually delete a DC. To quote again from MSDN:
"The ReleaseDC function releases a device context (DC), freeing it for use by other applications."
Steve
|
|
|
|
|
hi,
I have a recordset which contains the results of a query, and I want to get the number of records in the recordset.
I tried to use the GetRecordCount function, but I understood that I have to go through the whole recordset in order to get the number of records. So I have this loop in my code which is very inefficient:
while (!pSet->IsEOF()) //pSet is a pointer to the recordset
pSet->MoveNext();
I thouhgt to do an SQL query using COUNT, but it requires a simple query (something like: SELECT COUNT (*) FROM Table1 ) and my query is not a simple one. It contains selection of a number of records, and Inner joins of tables and an ORDER BY clause.
Is there another way to get the number of records in a recordset? Any suggestions?
|
|
|
|
|
Been a long time since i programmed in ADO but IIRC you don't need to
while (!pSet->IsEOF())
pSet->MoveNext();
pSet->MoveLast();
pSet->GetRecordCount();
Hope it helps
The statement below is true. The statement above is false.
|
|
|
|
|
Nope - I tried that and it doesn't work
It gives 1 record as the result...
|
|
|
|
|
U just move to the first record and now loop until the end of records take a variable and increment it inside the loop with MOVENEST() function.
the variable holds the total records count
|
|
|
|
|
I don't understand what you mean...
can you write some code maybe?
and by the way, I would rather not use a loop - it's not very efficient...
I need an efficient solution
|
|
|
|
|
Monty2 wrote: pSet->GetRecordCount();//something like this
This will simply give you the “high water mark” — the highest-numbered record yet seen as the user moves through the records.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Yeah - I know. That's why I need another solution...
Is there another way to get the number of records in a recordset other than going through the recordset with a loop or using COUNT?
-- modified at 9:23 Tuesday 16th May, 2006
|
|
|
|
|
SWDevil wrote: Is there another way to get the number of records in a recordset other than going through the recordset with a loop or using COUNT?
Have you considered/tried a stored procedure?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Ummmm - no. don't really know what that is...
|
|
|
|
|
|
Thanks - I'll look at the links
|
|
|
|
|
SWDevil wrote: Is there another way to get the number of records in a recordset?
You can use JOINs with the COUNT() clause. Simply put COUNT() around the columns that you are querying.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
I tried doing that (in SQL server) and it doesn't work...
|
|
|
|
|
Ok, so just use COUNT(*), leaving the JOIN and WHERE clauses intact.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Hi All,
I know that the compile options \Gh gets you the _penter and _pexit, which can be used to get function level timings.
However, now the trick is how does one get to the level of saying: Line 121 took 13ms, Line 122 took 14ms, etc...?
Has anyone got any ideas or documentation to read?
thanks,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
hi all,
I have a video Player.Everytime the video player open and plays a video file,the corresponding files should be stored in folder.
1.how can i create a folder automatically.
If i give Filename=c:\\Folder1,I got error.
Please help me
cheers
sangeet
|
|
|
|
|
ramyasangeet wrote: If i give Filename=c:\\Folder1,I got error.
That's not very clear. What are you doing with Filename, post some code ('If I give' is quite vague). And what error did you get ?
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Hi,
Thanks for the reply.
This is my coding.
CFile cf;<br />
CString filename;<br />
int xu_flag;<br />
CString s; <br />
if(i == 1)<br />
{ <br />
s.Format("%d", (xu_picno/2)+1);<br />
filename = "c:\\temp\\";<br />
filename+=s;<br />
filename+="F";<br />
filename+=".jpg";<br />
}<br />
else<br />
{<br />
s.Format("%d", (xu_picno/2)+1);<br />
filename = "c:\\temp\\"; <br />
filename+=s;<br />
filename+="R";<br />
filename+=".jpg";<br />
<br />
}<br />
xu_flag = cf.Open(filename, CFile::modeCreate | CFile::modeWrite);<br />
cf.Write(sp_temp, xu_len); <br />
cf.Close();
This coding is for storing each frame of video file in jpeg format.Using Xu_picno, i can able to retrive pictures.So everytime the pic no changes,the filename will also change.Like 1F,2F...
My problem is ,i have to store those picture in seperate folders.
So i need to create folder in runtime.how to do that.
help me please
cheers
sangeet
|
|
|
|
|
You can't create folder with CFile.
Use the _mkdir[^] function for that purpose.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
ramyasangeet wrote: s.Format("%d", (xu_picno/2)+1);
filename = "c:\\temp\\";
filename+=s;
filename+="F";
filename+=".jpg";
Why not use:
filename.Format("c:\\temp\\%dF.jpg", (xu_picno/2)+1);
ramyasangeet wrote: xu_flag = cf.Open(filename, CFile::modeCreate | CFile::modeWrite);
cf.Write(sp_temp, xu_len);
If the call to Open() fails, there's no need to call Write() or Close().
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
and CreateDirectory
whitesky
|
|
|
|
|
can u please give me an example.
Also do i need to declare _mkdir??
help me out
cheers
sangeet
|
|
|
|
|
ramyasangeet wrote: Also do i need to declare _mkdir??
What do you mean ?? You simply need to call this function with the name of the folder you want to create. Did you read the doc from the MSDN (the link I sent you) ? It's pretty obvious how to use it. Also, don't forget to include <direct.h> (also stated in the doc).
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
I suggest that you read msdn
CreateDirectory("c:\\test",NULL);
whitesky
|
|
|
|