|
I still do not understand what you're trying to do.
The string without the loop is in itself a valid query -
"Select Name from Test WHERE Team = 'IN'"
Why then are you trying to append the button text?
I'm asking you again - What is the string that you're expecting to create?
|
|
|
|
|
SELECT * FROM ODI WHERE Team = "India" AND Name = "SachinRameshTendulkar" like this one I've to built.
Upto AND I've built. The remaining part "Name" I've to get from 11 button's Text(I"ve created buttons using array).
|
|
|
|
|
Ok. I made a mistake when I posted the string it is going to produce.
I'm assuming that you're created only one query.
In that case, you're logic is just fine.
All you need is a ' at the very end.
stringw query;
query = L"Select Name from ";
switch(tabId)
{
case 17:
query += L"Test";
break;
case 18:
query += L"ODI";
break;
case 19:
query += L"T20I";
break;
default:
query += L"Test";
}
query += L" WHERE Team = '";
query +=country.trim();
query +="' AND Name = '";
for(int i = 0; i<m_pPlayerBtn.size();i++)
{
query += m_pPlayerBtn[i]->getText();
}
query += "'";
|
|
|
|
|
I've already tried this one. It brings all the 11 players name in to my "query" at a time. I want only one player's name at a time. Can you tell me this approach is correct? If it's wrong can you suggest me an alternative?
|
|
|
|
|
So that means you want to fire 11 different queries?
Then how about this -
for(int i = 0; i<m_pPlayerBtn.size();i++)
{
stringw query;
query = L"Select Name from ";
switch(tabId)
{
case 17:
query += L"Test";
break;
case 18:
query += L"ODI";
break;
case 19:
query += L"T20I";
break;
default:
query += L"Test";
}
query += L" WHERE Team = '";
query +=country.trim();
query +="' AND Name = '";
query += m_pPlayerBtn[i]->getText();
query += "'";
}
|
|
|
|
|
Sorry. I've done a mistake. Instead writing this code as a separate function, I should write it inside the button's click event. There getText() returns the name of the corresponding player. For loop isn't necessary at all.
I've truobled you a lot. Please forgive me.
|
|
|
|
|
Hi All,
I'm hitting my head against the wall third day about the following code:
#define PointerToMember(B)
template <bool A, typename B, typename C, C PointerToMember(B) D>
class One
{
public:
One() {};
};
template <typename B, typename C, C PointerToMember(B) D>
class One<true, B, C, D> : public One<false, B, C, D>
{
public:
One<true, B, C, D>() : One<false, B, C, D>() { };
};
template <bool A, typename B>
struct Two
{
template <typename C, C PointerToMember(B) D>
class OneUsage : public One<A, B, C, D> { };
};
template <typename B>
struct Two<true, B> : public Two<false, B>
{
template <typename C, C PointerToMember(B) D>
class OneUsage : public One<true, B, C, D> { };
};
struct S { int i;};
int main()
{
Two<true, S>::OneUsage<int, 1> two;
return 0;
}
With those two lines commented out, it compiles in all 3 compilers: GCC, VC++ 2008 and VC++ 2005. But, if instead of
#define PointerToMember(B)
...
Two<true, S>::OneUsage<int, 1> two;
you will make it this:
#define PointerToMember(B) B::*
...
Two<true, S>::OneUsage<int, &S::i> two;
it still will compile in GCC and 2008, but will fail in 2005 with error:
error C2955: 'Two<A,B>::OneUsage' : use of class template requires template argument list
with
[
A=true,
B=S
]
list4.cpp(30) : see declaration of 'Two<A,B>::OneUsage'
with
[
A=true,
B=S
]
error C2133: 'two' : unknown size
error C2512: 'Two<A,B>::OneUsage' : no appropriate default constructor available
with
[
A=true,
B=S
]
Looks like VC++ 2005 compiler does not like usage of pointer-to-member type declaration when inheriting templates with partial specialization. Is it a bug of VC++ 2005, or I break some C++ standard, and other two compilers are just more forgiving?
This code was taken from much more complex one just to show exact problem. Code compiled by both VC++ 2008 and GCC works with no issue and as intended.
Thank you!
|
|
|
|
|
OK, question still remains, but I solved the problem by moving declaration of pointer-to-member this way:
#define PointerToMember(B)
Two<true, S>::OneUsage<int S::*, &S::i> two;
Pay attention to this line:
Two<true, S>::OneUsage<int S::*, &S::i> two;
Basically, instead of saying to template in the declaration that passed variable is of type pointer-to-member, I just make typename "C" to be pointer-to-int-member. Problem with this is that now I don't know the final type of variable "D", and if I will ever need it, I would need to pass it separately, i.e. adding one more template parameter.
This variant compiles everywhere, but question still remains: what's wrong with previous one? It's more compact and straightforward...
|
|
|
|
|
I can't comment on what's wrong with your code in the context of VC++2005 - I don't tend to use pointers to members much and never as template arguments. However as your code is compiling and working on two other compilers I'd put it down to VC++2005 not being standard compliant in that area. I'd be tempted to try VC++2010, gcc 4.x and an EDG based as well and see what happens. If those three work then you can be fairly sure your code is standard.
One other point - templates with templated internal types are going to confuse most people. Make sure you keep a clean interface between your code and your users or they're going to end up cursing your name. Something like bind_first or make_pair to hide all the gribbly declarations they might otherwise have to make (and which are a godsend with C++0x and the auto keyword).
Cheers,
Ash
modified on Thursday, July 8, 2010 4:03 AM
|
|
|
|
|
Hi sir,
As i am new to CDataBase.
I want to know how can i connect to CDataBase using SQL and
create Table ,insert values and get the values.
Any link which will be helpful.
Or any sample example,as i am totally aware of CDataBase.
I am trying to create one sample application and test it
Thanks
Raj
|
|
|
|
|
Try searching the articles here on CodeProject, there are a number of examples.
It's time for a new signature.
|
|
|
|
|
Richard MacCutchan wrote: Try searching the articles here on CodeProject, there are a number of examples.
Hi sir,
If you know any link,please let me know.
I searched in CodeProject,but all i am not getting the beginner guidilines,as to how can i start .
Thanks
Raj
|
|
|
|
|
I am getting the impression that you are a Database beginner, so perhaps you should try to widen your search a little and use Google also.
It's time for a new signature.
|
|
|
|
|
Richard MacCutchan wrote: ...so perhaps you should try to widen your search a little and use Google also.
The least you could do is provide him a link.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
raju_shiva wrote: I am trying to create one sample application and test it
So what do you have so far?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi sir,
I have just created one Dialog Based application now,with the combo box and manually adding the values.
I am thinking of fetching the values from database and storing the values in the database.
As i am new,I dnt have any idea,how to start it.
I am struct at the start.
Regards
Raj
|
|
|
|
|
If you are using MFC, check out thee CRecordset and CDatabase classes. Although not required, you might also want to study up on DSNs.
Here is a semi-related article, but know that ones exist that are more suited to your need.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi All,
I have a MDI application. there I am creating three types of views.
I have a tree structure in Left side of frame window.
Whenever user double clicks an item in tree structure i will open a view.
Like that i will open many views.
Now my problem is whenever user clicks on the same item (previously opened)
Now i want to activate the previous view.
How to do this?
|
|
|
|
|
Use CFrameWnd::SetActiveView .
|
|
|
|
|
I have a view class CMyView.
Now all my opened views are of this class only.
All views are of this class only.How to activate this view.
SetActiveView() will take parameter of CView type.
Now my question is which CMyView type parameter i have to give?
I don't have variables of my created views.
|
|
|
|
|
You can pass in a pointer to CMyView as parameter to SetActiveView .
You will have to store pointers to the views that you have created.
|
|
|
|
|
I am using below code for creating view.
now where i have to store the view pointer.
POSITION curTemplatePos = AfxGetApp()->GetFirstDocTemplatePosition();
while(curTemplatePos != NULL)
{
CDocTemplate* curTemplate =
AfxGetApp()->GetNextDocTemplate(curTemplatePos);
curTemplate->GetDocString(Str, CDocTemplate::docName);
if(Str==ViewType)
{
Res = curTemplate->OpenDocumentFile(NULL);
if(Res==NULL)
{
MessageBox("Error creating view\t",ViewType, MB_ICONSTOP);
return FALSE;
}
break;
}
}
CMDIChildWnd* Chi = MDIGetActive();
|
|
|
|
|
Each document template holds all open documents of its type.
POSITION p = GetFirstDocTemplatePosition();
while (p != NULL)
{
CDocTemplate* pTempl = GetNextDocTemplate(p);
POSITION pdoc = pTempl->GetFirstDocPosition();
while (pdoc != NULL)
{
CMyDoc *pDoc = static_cast<CMyDoc*>(pTempl->GetNextDoc(pdoc));
}
}
And each document contains a list of its views
POSITION viewpos = pDoc->GetFirstViewPosition();
while (viewpos != 0)
{
CMyView *pView = static_cast<CMyView>(pDoc->GetNextView(viewpos));
}
|
|
|
|
|
I reached upto there.
Now i want to activate that view. How to do this?
How to activate that view?
|
|
|
|
|
I googled a bit and found an excellent answer to that question right here[^]
|
|
|
|