|
Like this????
DECLARE @num int, @id varchar(10)
declare @row_count int
SET @row_count = 0
DECLARE c1 CURSOR FOR
SELECT distinct num,id FROM table1
OPEN c1
FETCH NEXT FROM c1 INTO @num, @id
WHILE @@FETCH_STATUS = 0
BEGIN
SET @row_count = @row_count + 1
print "row count:" + convert(varchar,@row_count)
select * into #tmp from table2 t1
inner join table3 t3 on t1.id=t3.id and t1.num=t3.num
inner join table4 t4 on t1.id=t4.id and t1.num=t4.num
if not exists(
select * from #tmp Where t1.num=@num and t1.id=@id)
begin
PRINT "Deleted id:" + @id + " " + convert(varchar,@num)
delete from table1 where num=@num and id=@id
delete from table2 where num=@num and id=@id
delete from table3 where num=@num and id=@id
delete from table4 where num=@num and id=@id
end
FETCH NEXT FROM c1 INTO @num, @id
END
CLOSE c1
|
|
|
|
|
No like this
DECLARE @num int, @id varchar(10)
declare @row_count int
select
*
into #tmp
from
table2 t1
inner join table3 t3 on t1.id=t3.id and t1.num=t3.num
inner join table4 t4 on t1.id=t4.id and t1.num=t4.num
SET @row_count = 0
DECLARE c1 CURSOR FOR
SELECT distinct num,id FROM table1
OPEN c1
FETCH NEXT FROM c1 INTO @num, @id
WHILE @@FETCH_STATUS = 0
BEGIN
SET @row_count = @row_count + 1
print "row count:" + convert(varchar,@row_count)
if not exists(select * from #tmp Where t1.num=@num and t1.id=@id)
begin
PRINT "Deleted id:" + @id + " " + convert(varchar,@num)
delete from table1 where num=@num and id=@id
delete from table2 where num=@num and id=@id
delete from table3 where num=@num and id=@id
delete from table4 where num=@num and id=@id
end
FETCH NEXT FROM c1 INTO @num, @id
END
CLOSE c1
Best Regards!!!!
Carlos Antollini.
|
|
|
|
|
Im sorry I have an error
This is the correct line
if not exists(select * from #tmp Where num=@num and id=@id)
Carlos Antollini.
|
|
|
|
|
Thank you.
I'll try to run this.
I'll let you know the results.
|
|
|
|
|
Im sorry I have an error
This is the correct line
if not exists(select * from #tmp Where num=@num and id=@id)
Carlos Antollini.
Carlos Antollini.
|
|
|
|
|
use joins.. they are exactly for step 1 - 2-> and then delete this tables..
other thing: use nested table expressions (is this possible in SQL - Server.. don't know.. cause i use SQL)
but stored procedures would be better anyways..
Bernhard
|
|
|
|
|
I want to use farsi language in my project ,But the standard controls(Edit Box,Static text) can't show this language I use windows 2000 and I enabled Farsi language & installed Farsi fonts & changed Dialogs font to that font But it is don't any effect
Iman Ghasr-e-fakhri
|
|
|
|
|
I have the same problem. Please some one help
|
|
|
|
|
I am trying to add a few new event log messages to the program that reports its status to the event log. I had added all the corresponding entries to the .MC file and compiled it(using "MC" command), but after I ran updated executable, instead of needed test, I found the following message in the event vewer:
"The description for Event ID ( 7 ) in Source ( FSAINQ_Builder ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. The following information is part of the event: ."
Also, I tried to change the strings for existing messages, but event viewer DID not update those either.
Did lots of crazy and supersticious things like rebooting computer and restarting Event Viewer - nothing works.
If someone knows something on event logging API, message compiler, message recourse files(.RC), etc., please let me know what you've got in your bag.
Thanks in advance.
Kirill.
|
|
|
|
|
Do you have the correct path in the regsitry entry EventMessageFile? Because this is the typical message error when this happens.
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Carlos, I DO have a correct path.
In InitInstance(), this application creates the following registry key in the root of HKEY_LOCAL_MACHINE:
"\SYSTEM\CurrentControlSet\Services\EventLog\Application\<executable filename(without="" ".exe")="">\"
Then, it obtains complete path of its executable(using GetCurrentDirectory()) and then inserts this path under "EventMessageFile" entry in the root of key, specified above.
I tried moving this executable in variety of directories, and every time, the correct home path of executable would be displayed in regedit.
I am lost.
|
|
|
|
|
I've seen, somewhere, a tag that I can include to get my code snips to preserve their formatting. But I can't seem to find it now...
Thanks for the help,
Bill
|
|
|
|
|
<pre> ... code .... </pre>
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Thanks, John
CString str = "Some Code";
<\pre>
:-O
Thanks for the help,
Bill
|
|
|
|
|
I have a need to know "how busy" a system is on a regular basis. My program launches worker threads in response to requests from client programs. One of the requirements is that the execution of these asynchronous functions do not adversly effect interactive users on the same system.
To do this, I check the system load before launching a worker thread. If it is "too high" my program waits to launch the thread.
This application must run on NT 4 and W2K. I have tried three differnt approaches:
1. My first attempt was to use the WMI provider Win32_Processors and the LoadPercentage. This is advertised as being the average system load over the last 1 second. The problem is that it appears to wait for the second before returning a result! (see earlier post WMI Query too slow if you want the coee).
2. My second attempt is to use the perf lib api. I can't seem to get this to work properly, however.
3. My best solution so far (ugly as it is) is to have the WMI query running continuously on a thead. Sample the result whenever I need it. The frequency of the requests is in the 10 miilisecond range.
Here is some code I got of the internet that attempts to implement #2. It runs ok, but gets an error as explained below. If I could get this to work it would solve all my problems and avoid using the dreaded option 3 (chich does actually work).
Or... is there a better way to do this I haven't thought of yet.
#include "stdafx.h"
#include<pdh.h>
#include "CPUUsage.h"
#pragma comment(lib, "pdh")
//#include "winerror.h"
CCPUUsage::CCPUUsage(LONG nMinTicksBetweenSamples) {
m_nMinTicksBetweenSamples = nMinTicksBetweenSamples;
m_msLastTick = GetTickCount();
PDH_STATUS pdhs = PdhOpenQuery(NULL, 0, &m_hQuery);
pdhs = PdhAddCounter(m_hQuery,
TEXT("\\Processor(_Total)\\% processor time"), 0, &m_hCounter);
}
CCPUUsage::~CCPUUsage() {
PdhCloseQuery(m_hQuery);
}
int CCPUUsage::GetUsage(PBOOL pfNewSample ) {
BOOL fNewSample;
if (pfNewSample == NULL)
pfNewSample = &fNewSample;
*pfNewSample = FALSE;
DWORD msCurrentTick = GetTickCount();
DWORD msLastTick = m_msLastTick;
if (msCurrentTick < msLastTick) {
// Wrap around, always sample
*pfNewSample = TRUE;
} else {
if ((msLastTick + m_nMinTicksBetweenSamples) < msCurrentTick) {
// It's been long since the last sample, get a new sample
*pfNewSample = TRUE;
}
}
if (*pfNewSample) {
if ((DWORD) InterlockedExchange((PLONG) &m_msLastTick, msCurrentTick) == msLastTick) {
PdhCollectQueryData(m_hQuery);
PDH_FMT_COUNTERVALUE pdhfcv;
PdhGetFormattedCounterValue(m_hCounter, PDH_FMT_LONG, NULL, &pdhfcv);
// The PDH_FMT_COUNTERVALUE structure contains a status variable. This is returning with a value of 0x800007d1 (which says there is no instance of the counter)
m_nLastSampledCPUUsage = pdhfcv.longValue;
} else {
*pfNewSample = FALSE;
}
} else {
GetLastError();
}
return(m_nLastSampledCPUUsage);
}
Thanks for the help,
Bill
|
|
|
|
|
Does it hurt performance to leave the Debug Info in the release build? I'm not worried about the executable size getting bigger, but the speed of the application. The size of the data set for this application is on the order of 256MB to 1GB so the added size of the executable will be insignificant..
Thanks In Advance,
John
|
|
|
|
|
No, AFAIK. The generated code is the same, no matter if you turn debug info on or off.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I want to print on paper in tray #2 of my printer. I've looked at the DEVMODE structure and I can do virtually anything such as change the print orrientation, but not set which tray the paper comes from. If I use CPrintDialog dlg(TRUE, 0) I can then select which tray I use from the dialog, but I need to do this programatically with no dialog coming up.
Anyone know how I can do this please?
Thanks
|
|
|
|
|
You need to use the dmDefaultSource (and dmFields) members of the DEVMODE structure. If you look in MSDN under DEVMODE (for Windows GDI: Platform SDK) you will see the values that are defined. In newer versions of C++, this has been phased out and is now unsupported (although it still 'works'). This is problematic because printer manufacturers never decided on a standard convention for numbering the trays of a printer. Some numbers will work for all drivers (if memory servers 4 = Manual Feed for all known printer drivers). I would suggest getting a Win32 SDK programming book. Know that although this may work for YOUR version of the printer and driver, it MAY or MAY not work for other printer/driver combinations. It may not even work with different versions of the same driver for the same printer. This is a use at your own risk type of feature. I implemented something similar to this for a company that I worked for. It was very problematic. We had to update all of the customer databases with the printer/driver specific information for this to work.
I would get a copy of Win32 SDK Programming (a big blue book). Unfortunatly I don't recall the authors names.......Hope I could help.
|
|
|
|
|
I want to use HTML View in my application, but the HTML file is loaded from database, and there is some picture, how to load it to HTML VIEW?
|
|
|
|
|
Some ideas:
1) save the picture to a temp file, then change each reference to that picture in the HTML source
2) use a .mht file, that has embedded pictures
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
However, If I know how IE works, I think it will help me more.
Thanks your help!!!
What I needed maybe you have, so let's help each other.
|
|
|
|
|
Well, I would be glad to help you, if I could, but I can't see how.
If all you do is reading from the database, and you can convert each "HTML+pictures" record to a ".mht" record, then no problem.
If you need to write such records from your program, obviously you have to know how to produce a ".mht". What I know about it is that it's a multipart MIME message, in fact if you rename it to .eml you can open it with OutlookExpress.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hello,
I am trying to figure out the best way to go about implementing timers in a list control.. What I need to do (as far as I can tell) is get the total number of items currently in the list and then "on the fly" assign a timer member variable to each item in lets say row 5.. anyone know where I should start.. Getting the total numbers of items is easy but I cant figure out how I can assign a member variable to each of these items in row 5 so my timer can keep track of the time remaining.
Rob
|
|
|
|
|
One way to do this would be to derive a new class from CList. The new class would override the list maintenance methods (AddTail, SetAt etc.) that you use. Your new methods could then store the necessary values in an array of some sort.
Hope this helps ,
Bill
|
|
|
|