|
Hi there.
We have some stored procedures on a remote SQL Server.
Now, from my local machine using C++ I want to call a stored procedure.
Please provide sample code if available for the same.
Incase any further information required, please let me know.
Thanks and Regards
PanB
|
|
|
|
|
Let's me try to use Google for you...^
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]
|
|
|
|
|
Hi all,
I have made a dialog based application in vc-2008. I have made 2 more dialog boxes...
Now what i have to do is on button click event 1st dialog box is called, so first dialog box OnInitDialog function is being called in that function second dialog box DoModal function has been called... Now what i want is if second dialog box return 1 i.e its successful then only first dialog box should be constructed and do its processing otherwise it should not be constructed.....
for example
CFirstDialog dlg;
dlg.DoModal();
BOOL CFirstDialog::OnInitDialog()
{
CSecondDialog dlg1;
int ret_val = dlg1.DoModal();
if(ret_val == 1)
return true;
else
return false;
}
but this code is not solving my problem...
its giving me a dialog box(first) in not working condition....
how to do this....
can anybody help me in this...
thanks in advance
|
|
|
|
|
Why do you want to do that in the OnInitDialog from CFirstDialog ? Can't you simply move the condition check at the place where you create CFirstDialog originally ? There you first create CSecondDialog and if the return condition is not what you expect, then you don't create CFirstDialog. Seems a bit better than putting that in the OnInitDialog...
|
|
|
|
|
Cedric's answer is good - you're testing too late. Why go to all the bother of making a dialog then throwing it away?
Saying that, you may have a very good reason.
So...
As you're a VCProgrammer, you should be familiar with documentation. OnInitDialog / WM_INITDIALOG has some too. Here's an extract:
Return Values
The dialog box procedure should return TRUE to direct the system to set the keyboard focus to the control specified by wParam. Otherwise, it should return FALSE to prevent the system from setting the default keyboard focus.
You don't get to make up the meaning of returns values for messages you didn't invent. Otherwise windows programming would be a whole lot more... interesting...
I'm pretty sure you can call EndDialog from within OnInitDialog though, which would give you a hacky answer - but Cedric's solution would be a lot cleaner.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
modified on Thursday, February 12, 2009 5:05 AM
|
|
|
|
|
just call EndDialog() instead of return false;// dialog should not be created
aks
|
|
|
|
|
Hi All,
I have used a List box control. But i cant show the automatic scroll down when something added in the list box. I cannot see which item added recent. If i want to see i have to scroll down by mouse.
Thanks to all
Regards
Munna
|
|
|
|
|
Use the CListBox::SetTopIndex()[^] function. Pass the index of newly add item to this function to bring that item to visible.
|
|
|
|
|
Additionally to what Naveen said, there is also CListCtrl::EnsureVisible[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi All,
Is there any API to know about the 32 or 64 bit machine?
|
|
|
|
|
|
Hello
I would like to create the project using c++ to read and write to binary file ( actually the file required to read and write is a RAW image file). The project should be win32 console application. Could you show me how to do it (step by step) ? The code I could write but where to write and how to connect the c++ program to the binary file I do not know
thank you very much.
|
|
|
|
|
Visual Studio provides you the skeleton of a console application, so the first part of your requirements is simply accomplished.
Writing and reading a binary file is pretty simple (just read the documentation [^]- For sample code, see for instance [^]).
If you find cumbersone (at first sight it may appear as such) C++ iostream programming, then you have two options:
- Going back to
VB6 (just kidding ). - Using goldie/oldie
C Stream I/O [^].
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]
|
|
|
|
|
In my code, I have created a Popup Menu containing a large number of menu items (does not fit in a single view). I display the same using TrackPopupMenuEX on the Menu handle.
The first time around when the Menu pops up, the the top most items of the menu are visible. Now if I scroll down the menu so that some other items are visible and close the menu in this state, the next time around when the same menu is popped up, the menu area and items visible is the same as When I had closed the menu in previous operation. The previous closing state of the menu is some how getting saved automatically.
I want to change this behavior. I want to change it such that the menu area visible on popup starts with the menu item I specify (either by Command ID or Position). Is this possible? How can I achieve it.
Thanks in advance..
P.A.Ajay Kumar M.Tech(IT) B.Tech(CS)
|
|
|
|
|
pa_ajaykumar wrote: I want to change this behavior
No, what you want to change is how you organise that popup's UI - think about your users - having a menu that large is insane.
Either categorise the menu entries by function type, or alphabetically, or something that makes sense, and then use those categories to populate sub-menus.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Well, the thing is that this pop-up menu is not going to be a right click context menu. Its a font selection menu which is going to be popped up over a button. Its bound to have so many items due to the number of fonts and the menu is already hierarchical (families as main menu items and styles as sub menu items). So further grouping is not an alternative.
P.A.Ajay Kumar M.Tech(IT) B.Tech(CS)
|
|
|
|
|
What's wrong with the standard font select dialog? Or grouping the fonts alphabetically (split fonts into groups starting with A-F, G-M, N-T, U-Z).
Anyway - the only way I know of to get the menu to forget it's selected location is to recreate it each time you show it.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi All,
I need to display a blinking cursor on the view but without using any control. How to do it?
Thanks
|
|
|
|
|
The blinking cursor is called a Caret and can be created using the CreateCaret function and shown using the ShowCaret function.
«_Superman_»
|
|
|
|
|
Hi Experts,
I have ATL DLL with Addition() method,
I calling this function from another MFC application with no argument
Code goes like :
Assume no syntax errors
CLSID cls_id;
CLSIDFromProgID(L"DLLTest.MyObject",&cls_id);
CComPtr<IDispatch> pService;
HRESULT hr = pService.CoCreateInstance(cls_id, NULL, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER);
if(hr == S_OK)
{
DISPID Disp_id;
CString bsvalue;
CComVariant Result;
OLECHAR *member=_T("Addition");
DISPPARAMS param = {NULL,NULL,0,0};
hr = pService->GetIDsOfNames(IID_NULL,&member,1,LOCALE_SYSTEM_DEFAULT,&Disp_id);
if(S_OK == hr)
hr = pService->Invoke(Disp_id,IID_NULL,LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD,¶m,&Result,NULL,NULL);
else
MessageBox(L"Could not get disp id",L"MSG",MB_OK);
}
else
MessageBox(L"No Interface",L"MSG",MB_OK);
This code works fine but,
now I want to call same function Addition() with two arguments, I have made respective chages in DLL, so please give me solution or hint
|
|
|
|
|
[Hint]If you post your code formatted in a <pre> block, we can read it easier, which means we're more likely to answer you question...[/Hint]
You want to add parameters to the param variable. They will be VARIANT s packaged as follows (note: I'm presuming they're 32-bit integer arguments, of value 12 and 45 respectively):
VARIANTARG args[2];
V_VT(&args[0]) = VT_I4;
V_I4(&args[0]) = 12;
V_VT(&args[1]) = VT_I4;
V_I4(&args[1]) = 45;
param.nArgs = 2;
param.rgvarg = args;
Add this code between a) declaring param and b) using param .
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I am geting compile time error:
Error 1 error C2039: 'nArgs' : is not a member of 'tagDISPPARAMS'
|
|
|
|
|
Should be cArgs - mix up copying code from where I've used DISPPARAMS .
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Done!!!
I made slide changes 'cos of application was crashing due to invalid arguments.
VARIANTARG args[2];
V_VT(&args[0]) = VT_I4;
V_I4(&args[0]) = 12;
V_VT(&args[1]) = VT_I4;
V_I4(&args[1]) = 45;
param.cArgs = 2;
param.rgvarg = args;
param.cNamedArgs=0;
param.rgdispidNamedArgs=0;
thanx for replying.
|
|
|
|
|
IDispatch* DllBase::CreateClassComDispatch(BSTR sClassName)
{
CLSID clsid;
IUnknown *pUnk;
IDispatch *pDisp;
HRESULT hr;
CLSIDFromProgID(sClassName, &clsid);
hr = CoInitialize(NULL);
if(FAILED(hr))
return FALSE;
hr = CoCreateInstance(clsid,NULL,CLSCTX_ALL,IID_IUnknown,(void**)&pUnk);
if(FAILED(hr))
return FALSE;
hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pDisp);
if(FAILED(hr))
{
pUnk->Release();
return FALSE;
}
return pDisp;
}
GetPrinterList(char* printLib, char* printersUrl, char* username, char* password)
{
char* retValue = NULL;
HRESULT hr;
DISPID idd;
VARIANTARG varResult;
IDispatch *pDisp;
try
{
VariantInit(&varResult);
retValue = NULL;
//lib
_bstr_t bstrLib = _bstr_t(printLib);
pDisp = CreateClassComDispatch(bstrLib.GetBSTR());
if(pDisp == NULL)
return NULL;
//function
LPOLESTR str = L"GetPrinterList";
//params
int ParamsNumber = 3;
VARIANTARG avarParams[3];
for(int i=0;i<paramsnumber;i++){>
::VariantInit( &avarParams[i] );
}
_bstr_t bstrTemp1 = _bstr_t(password);
avarParams[0].vt = VT_BSTR;
avarParams[0].bstrVal = bstrTemp1.copy();
_bstr_t bstrTemp2 = _bstr_t(username);
avarParams[1].vt = VT_BSTR;
avarParams[1].bstrVal = bstrTemp2.copy();
_bstr_t bstrTemp3 = _bstr_t(printersUrl);
avarParams[2].vt = VT_BSTR;
avarParams[2].bstrVal = bstrTemp3.copy();
DISPPARAMS params = { avarParams, NULL, ParamsNumber, 0 };
//get ID
hr = pDisp->GetIDsOfNames(IID_NULL,&str,1,NULL,&idd);
if(!FAILED(hr))
{
hr = pDisp->Invoke(idd, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
if(FAILED(hr))
retValue = NULL;
else
{
_bstr_t retvalue = _bstr_t(varResult.bstrVal);
retValue = strdup((char*)retvalue);
}
}
else
{
retValue = NULL;
}
for(int j=0;j<paramsnumber;j++){>
::VariantClear( &avarParams[j] );
}
::VariantClear( &varResult );
return retValue;
}
catch(...)
{
}
return NULL;
}
|
|
|
|