|
OK - my previous answer was right, but also wrong. Your current error is because you're using CreateParameter and Append wrong. Look at this example for CreateParameter and Append[^]. You have to create the parameter and append it, then set its value.
So, you need code like this:
_ParameterPtr p = pCmd->CreateParameter("strIsbn",adVarChar,adParamInput,sizeof(char),vtMissing);
pCmd->Parameters->Append(p);
p->Value = variant_t("test value");
HOWEVER - this will throw an exception when you assign the value, because you've said the parameter is a VARCHAR(1). Change the sizeof(char) to the actual length of the VARCHAR column as defined in the database schema and you've got a chance of the code working!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanx a lot for ur replies.
|
|
|
|
|
If you compare your code with the article content, then you may find:
vital_parsley2000 wrote: pCmd->CreateParameter("strIsbn",adVarChar,adParamInput,sizeof(char),vtMissing);
should possibly be
paramIsbn = pCmd->CreateParameter("strIsbn",adVarChar,adParamInput,-1,vtMissing);
Where paramIsbn must be declared as _ParameterPtr
Moreover you should replace
vital_parsley2000 wrote: pCmd->Parameters->Append((_variant_t)strIsbn);
with something like this
paramIsbn->Value = _variant_t( strIsbn );
pCmd->Parameters->Append(paramIsbn);
The same for all the other parameters
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanx alot .Your changes worked!
One last thing regarding the error;When i use GetLastError() the message it returns is which error.Because when i used GetLastError()i got the message Operation completed successfully.What did it mean ?
|
|
|
|
|
GetLastError should be called immediately after a function failure, otherwise it may reports success because the last operation was indeed executed successfully (i.e. other function calls overwrite the last error value).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thx for ur reply.Appreciate your help.
The code above i have ,i would like to know if its open for sql injection ?
How do i avoid it ? it is open for sql injection.
i have read some articles on sql injections and have understood that parameterized values could be injected for malicious values.
So,would like to know if it is open for sql injection ?
|
|
|
|
|
vital_parsley2000 wrote: The code above i have ,i would like to know if its open for sql injection ?
I don't believe so - SQL injection occurs when you build the query/command string embedding the parameter values explicitly - the classic example (in comic form) is this one[^]
In fact, if you look at the Wikipedia entry for SQL injection[^], they explicitly mention parameterised queries (like you have here) as a mechanism for avoiding SQL injection.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you for your reply.
|
|
|
|
|
Hi all,
please help on debug assert error while using domodal().
CDeleteJed d(this);
d.DoModal();
when i debug i found assert as followed
VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
ASSERT(ContinueModal());
if (!AfxPumpMessage()) {
AfxPostQuitMessage(0);
return -1;
}
=>
BOOL AFXAPI AfxPumpMessage()
{
CWinThread *pThread = AfxGetThread();
if( pThread )
return pThread->PumpMessage();
else
return AfxInternalPumpMessage();
}
debug assertion failed . please help
Thanks in adv.
|
|
|
|
|
I think the problem is in this line.
CDeleteJed d(this);
Dont pass "this" to the constructor.
Just check it.
It should work fine.
Thanks,
Sujeet
|
|
|
|
|
thanks for reply.I use without "this" key but result is same..
|
|
|
|
|
I developing a SDI based application. the VIEW area have some rectangle and text messages the problem here is that when i maximize the VIEW area every thing in the view area disturbed and misplaced. can anyone help me solving this problem, that when i maximize the application the every thing in the VIEW area maximize accordingly.
Thanks
kkkljj
|
|
|
|
|
You need to resize the rectangle and text messages according to window resized when its maximized.
chk this.ResizableFormView[^]
and CResizableFormView[^]
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I want to create a local webservice and pass soap message from a browser to this webservice.
i.e. lets say i have opened one web page in my browser. On clicking of one button in browser, i want to pass a soap message to a locally created webservice in vc++.
Can anyone help how to do this?
Thanks,
Sujeet Kumbhar
|
|
|
|
|
You have to use INET api to do so! read more about it in your local copy of MSDN.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
HALLO and thanks for the answer, i have the followinbg code in the view.cpp file:
BEGIN_MESSAGE_MAP(CTest_View, CEditView)
ON_WM_LBUTTONDOWN(OnCursorLine) // this should get if the user pressed the return or the up or down arrows
END_MESSAGE_MAP()
// where should i handle WM_KEYDOWN event?
CTest_View::OnCursorLine()
{
if(nChar==VK_DOWN & nChar==VK_RETURN)// how can i get the value of nChar?
}
When i start ma SDI application and press the Return or arrow up/down the Debuger does not go to the OnCursorLine ().
What should i do?
|
|
|
|
|
ON_WM_LBUTTONDOWN gets called when the user presses the left mouse button and not on the key press. I corrected my post after someone pointed out the mistake and suggested you to use the WM_KEYDOWN message instead. You can perform a check for VK_DOWN & VK_RETURN.
You can add the WM_KEYDOWN event in the same manner you do for WM_LBUTTONDOWN
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
i did it in this way but it did not work when i press any or the Return Key.
BEGIN_MESSAGE_MAP(CTest_View, CEditView)
ON_WM_KEYDOWN(WM_KEYDOWN,OnKeyDown)
END_MESSAGE_MAP()
void CTest_View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
}
|
|
|
|
|
Please check PreTranslateMessage!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
i ckecked the PreTranslateMessage(MSG *pMsg), so i tried to override it but the debugger does come to it when i pressed any key.
BOOL CTest_View::PreTranslateMessage(MSG *pMsg)
{
// Do stuff
return true;
}
|
|
|
|
|
are you adding your event handlers manually?
why not use the wizard for the same because ON_WM_KEYDOWN() is what you need to add to the message map.
The VS editor adds void Cyourclassview::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
which later on gets called by the framework from where you can call your function to execute
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
modified on Friday, May 22, 2009 5:27 AM
|
|
|
|
|
You don't need the parameters you've passed to ON_WM_KEYDOWN - the line shown below is sufficient:
ON_WM_KEYDOWN()
I added a keydown handler to a sample SDI app's view and it captured key-presses fine, including the Return key.
Oh - one other thing - you should call the default CView key-down handler for any messages you don't handle. My WM_KEYDOWN handler (with no functionality) looks like this:
void CsditryView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
in the CTest_View.cpp i wrote this:
BEGIN_MESSAGE_MAP(CTest_View, CEditView)// CTest_View Class is derived from CEditView Class
ON_WM_KEYDOWN()
END_MESSAGE_MAP()
/
/
/
void CTest_View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar == VK_RETURN)
{
}
CEditView::OnKeyDown(nChar, nRepCnt, nFlags);
}
But it stiil not work???
|
|
|
|
|
Looking at one of your other messages where you show your PreTranslateMessage override - you return TRUE from your PreTranslateMessage override and if do that, you're telling MFC that you've done something with the message and it shouldn't be passed on to your window's message handlers. Try altering the return from PreTranslateMessage to FALSE...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
i change it but nothing work.
BEGIN_MESSAGE_MAP(CProSeS_SQLTalk_View, CEditView)
ON_WM_KEYDOWN()
END_MESSAGE_MAP()
void CTestView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar == VK_RETURN)
{
}
CEditView::OnKeyDown(nChar, nRepCnt, nFlags);
}
///////////////////////////////////////////////////////////////////////////////////////////
BOOL CTest_View::PreTranslateMessage(MSG *pMsg)
{
if(pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam == VK_RETURN)
{
//int bIsShiftKeyDown=(int)::GetAsyncKeyState(int nvKey);
}
}
return FALSE;
}
|
|
|
|