|
the problem is not the SQL command but how you build the string...
you cannot write like you did, but change to this:
SqlCmd.Format("SELECT TOP %u * FROM <code>"</code>
<code>"</code>(SELECT TOP %u * FROM %s ORDER BY time DESC) as t1 <code>"</code>
<code>"</code>WHERE time not in (SELECT TOP %u time FROM %s ORDER BY time DESC) as <code>"</code>
<code>"</code>ORDER BY time",
m_RcPerGrp, m_CntDispRc, m_TableName, tmp, m_TableName);
moreover, you should use parametrized query objects to add some parameters to your query, rather than build a CString yourself...
for your query, i suggest you this optimization:
SELECT TOP :1 *
FROM
(SELECT TOP :2 * FROM :3 ORDER BY time DESC) as t1
WHERE
t1.time NOT IN
(SELECT TOP :4 time FROM :5 ORDER BY time DESC)
ORDER BY t1.time
-- modified at 11:08 Sunday 11th November, 2007
|
|
|
|
|
Thanks very much.
I've never used parametrized query objects.
If it is not difficult, I should follow you suggestion.
Maybe I should find some sample code.
|
|
|
|
|
followait wrote: there is no runtime error.
From the compiler, linker, or your program?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I create a CTreeCtrl control,but i cannot recieve the "TVN_ITEMEXPANDED" message.
the code:
m_pTreeCtrl=new CTreeCtrl();
m_pTreeCtrl->Create(TVS_HASBUTTONS |
TVS_HASLINES | TVS_LINESATROOT | TVS_FULLROWSELECT |
WS_TABSTOP|WS_CHILD|WS_VISIBLE|TVS_SINGLEEXPAND ,
CRect(0,0,20,20),
this,IDC_DROP_TREE);
ON_NOTIFY(TVN_ITEMEXPANDING, IDC_DROP_TREE, OnItemexpandingTreeDocuments);
Thanks!
|
|
|
|
|
If your using a CView derived class to host this in, you would want to make your code look something like the following...
//////////////////////////////////////////////////
// Generated message map functions
protected:
CTreeCtrl* m_pTreeCtrl;
//{{AFX_MSG(CTest234View)
//}}AFX_MSG
afx_msg void OnItemexpandingTreeDocuments(NMHDR* pNMHDR, LRESULT* pResult);
DECLARE_MESSAGE_MAP()
/////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CTest234View, CView)
//{{AFX_MSG_MAP(CTest234View)
//}}AFX_MSG_MAP
ON_NOTIFY(TVN_ITEMEXPANDING, IDC_DROP_TREE, OnItemexpandingTreeDocuments)
END_MESSAGE_MAP()
////////////////////////////////////////////////////
void CTest234View::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
m_pTreeCtrl=new CTreeCtrl();
if (m_pTreeCtrl) {
m_pTreeCtrl->Create(TVS_HASBUTTONS |
TVS_HASLINES | TVS_LINESATROOT | TVS_FULLROWSELECT |
WS_TABSTOP|WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_SINGLEEXPAND ,
CRect(0,0,200,200),
this,IDC_DROP_TREE);
HTREEITEM hFirst=m_pTreeCtrl->InsertItem("First",NULL,NULL,NULL,TVI_SORT);
if (hFirst) {
HTREEITEM hSecond=m_pTreeCtrl->InsertItem("Second",NULL,NULL,hFirst,TVI_LAST);
}
}
}
void CTest234View::OnItemexpandingTreeDocuments(NMHDR* pNMHDR, LRESULT* pResult)
{
TRACE("Got here\n");
}
|
|
|
|
|
Well, CTreeCtrl derives from CObject so it'll probably throw a CMemoryException if it fails on "new" so my pointer check will probably never get reached on an error so it would be better located in a try/catch and I forgot to check the BOOL result from "Create" but you get the general idea.
|
|
|
|
|
thanks bob16792!
I create a tree control in my CDialog class, not CView class. well, I check my pointer is valid on "new" and the tree control I create appears on my dialog interface, so "Create" is successful.
If I drag a tree control on my dialog interface from the control box in the vc++, it can recieve the message,"VN_ITEMEXPANDED".
I don't know why the tree control that I create cannot recieve the message "VN_ITEMEXPANDED",but it can recieve the message "NM_CLICK".
|
|
|
|
|
|
Enviroment:
VC 6.0
SqlServer 2000
Demand:
For example,
<br />
_Recordset m_pRS;
...
<br />
<br />
Thanks very much, a little urgent.
-- modified at 3:54 Sunday 11th November, 2007
|
|
|
|
|
i created many dialog box's..
While i run the pgm the first one i created appears first...
how can i change so that when i run it, some other dialog box appears first(except the first one i created)
|
|
|
|
|
|
Change the order that they are created/shown?!?
I guess we need to see some code pertinent to what you are describing to understand what you are doing so that we might be able to offer a better suggestion but with what data you've provided in your post, we are limited to offering vague and general descriptions that really help no one.
Please offer more details.
|
|
|
|
|
i created many dialog box's..
While i run the pgm the first one i created appears first...
how can i change so that when i run it, some other dialog box appears first(except the
first one i created)
|
|
|
|
|
|
If I define a variable in a function, its scope remains local to that function.
Suppose I define a new instance of a class and a pointer in a function. Is the pointer local to the function? Can it be referenced outside the function? Do I have to declare the pointer in the header if I want to use it outside the function?
For example:
X::SomeFunction()<br />
{<br />
int ABC = 0;<br />
Y* pYY = new Y; //Creates new instance of class Y
}
Integer ABC is limited in scope to function SomeFunction().
Is there any limitation to the scope of pYY ? Can pYY be used in any other function other than SomeFunction() ?
Thanks
|
|
|
|
|
The scope of the variable pYY itself is limited to X::SomeFunction . However, given that the object that pYY is pointing to has been allocated on the heap that object continues to exist beyond X::SomeFunction . You could for instance return pYY from X::SomeFunction and use it at the caller site.
|
|
|
|
|
Hello..
Is there anyone here have the code for detecting MAC address in windows XP in C++. Im using Visual C++ 6.0. Thank you
|
|
|
|
|
|
GetAdapterInfo requires the iphlpapi.lib/h. It seems that i dont have that lib and header file. I tried to download it separately and i try run the sample program from msdn but it still have all these syntax error which i couldnt understand why it occured (eg: missing ; but i see that there is no problem with the syntax). Currently im using Visual C++ 6.0. Must I upgrade the latest SDK and install the latest Visual C++. The latest is Visual C++ 2005 right? Since im still a student doing my final year project, i found that im kinda slow in this. What are other steps that i could do to upgrade my programming kit and also, is there any code that can provide me a full code to detect MAC address?
|
|
|
|
|
Go to the very FIRST Syntax error, and see how it occurred. There may be a Header Missing, but often you can write your own to get out of a bind. The most common reason with downloaded stuff like that is, incorrect or missing manifest constants, or esoteric looking typedeffed names, ultimately resolving to an int of the correct size. A bit of experimentation is both educational, and often gives less headaches than upgrading the entire SDK.
Regards,
Bram van Kampen
|
|
|
|
|
No you do not need to upgrade from VC++ 6.0 just to use the IP Helper API. And yes the latest Visual C++ production release from Microsoft as of date is Visual C++ 2005. As for the syntax errors you should probably just listen to Bram van Kampen!
|
|
|
|
|
Thanks. I will try my best to solve this problem. Thanks again. Hopefully if i have any problem, you guys can help me right? Really appreciate that. Thanks a lot for the tips.
|
|
|
|
|
Hello,
Does anyone know how to get files list in a directory in c++? i searched it on google, i didnt find proper information about it?
can somebody know where i can get more specific information about it?
thanks
|
|
|
|
|
Hi,
kernel32.dll holds FindFirstFile() and FindNextFile() functions for this.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Gofur Halmurat wrote: Does anyone know how to get files list in a directory in c++?
Technically, C++ has no such functionality. You can, however, use FindFirstFile() and FindNextFile() .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|