|
How can I execute a SQL command using the OLE DB Consumer Templates? I don't want anything complicated like returning data, I just want to do a bunch of INSERT and UPDATE statments at once.
|
|
|
|
|
This was based on one of the MSDN samples. You have to have an open CDataSource.
HRESULT CAbstractDatabase::ExecuteSQL( LPCTSTR pszSQL, BOOL bShowErrors /* = TRUE */ )
{
// DataSource object must be initialized.
HRESULT hr;
if( m_DataSource.m_spInit.IsEqualObject( NULL ))
return E_INVALIDARG;
CSession conn;
CCommand<cnoaccessor,cnorowset,cnomultipleresults> cmd;
// Open session using datasource.
hr = conn.Open( m_DataSource );
if( FAILED(hr) )
{
if(bShowErrors)
DisplayOLEDBErrorRecords( hr );
return hr;
}
// Open command using session.
hr = cmd.Open( conn, pszSQL );
if( FAILED(hr) )
{
if(bShowErrors)
DisplayOLEDBErrorRecords( hr );
}
// Close command and session and return result.
cmd.Close();
conn.Close();
return hr;
} // ExecuteSQL
tangle@micron.net
|
|
|
|
|
Dear all,
How can I declare a variable so that all cpps in my MFC project can access the
variable?
Thanks.
Vickie
|
|
|
|
|
in whatever.h:
extern int myGlobalVariable;
in whatever.cpp
int myGlobalVariable = 0;
in any file you want to use myGlobalVariable:
#include "whatever.h"
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I can't get it work even I have followed what you'd said, since there are many others header files included in my cpps. Will this be the reason leading to my errors?
Thanks a lot!
|
|
|
|
|
Be sure to include the header with the 'extern' wherever you are going to use it. Or stick the header include in your stdafx.h
|
|
|
|
|
Like this (applies to C++ not just MFC):
yourcode.h:
extern globalVariableType YourGlobalVariable;
yourcode.cpp:
globalVariableType YourGlobalVariable;
This is freqently use for making the MFC CWinApp class global like this:
extern CMyApp theApp;
(this is because theApp is already defined in your MyApp.cpp file by MFC). This nicely replaces:
((CMyApp*)AfxGetApp())->Bogus();
with:
theApp.Bogus();
Hope this helps
--------------------------------
Todd C. Wilson (tcw@nopcode.com)
www.nopcode.com
ICQ: 5638028
"I picked up a Magic 8-Ball the other day and it said 'Outlook not so good.' I said, 'Sure, but Microsoft still ships it.'"
|
|
|
|
|
IE programming is one area that I am lacking, so I have to ask: What is the easiest way (if any way) to obtain the text in an running separate instance of IE's window? In this case, it would be the text from controls that are of the "Internet Explorer_Server" window class.
The end result would be a call that I could make that would populate a buffer with all of the text (or up to a specified amount of text) in that control instance.
This would be similar to a cut and paste operation, but without involving the standard clipboard (ie, would not trash any existing text in CF_TEXT format that is already there).
Can this be done?
-=- James.
|
|
|
|
|
i might be tempted to grab the stuff off the clipboard into a buffer then send a few messages to the ie window to select all and copy ... then grab that text into another buffer and restore the first buffer
prolly a better way but ie stuff isnt my strong point either
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
> i might be tempted to grab the stuff off the clipboard into a buffer
> then send a few messages to the ie window to select all and copy
I would be too, but:
o The "Internet Explorer_Server" window does not respond to WM_COPY or EM_SETSEL messages
o That would cause a visual "blip" on the target window, which is undesired.
But thanx for the response, anyway.
-=- James.
|
|
|
|
|
I'd like to program a ftp-server.
Can anyone tell me, what i have to do
in order to set up one?
A little bit c++ code or a link
would be nice...
thanks...
FoxHunter
|
|
|
|
|
well foxy its not quite so simple unfortunately.
"a bit of code ... would be nice..." would amount to a few thousand lines of code at the least.
maybe you should research the basic stuff of network programming, multi-threading and the ftp protocol as a good start.
its not rocket science in theory but getting a good ftp server that actually works and is scalable, robust and efficient is a bit of an art.
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
"I'd like to build my own B2 bomber, could you please point me to somewhere I can get all the parts for free and tell me how to put them together? Just a short explanation would be nice... thanks..."?
|
|
|
|
|
Ok... it wasn't quite that drastic
Adam
cabadam@houston.rr.com
|
|
|
|
|
Can anyone tell me if the following code is correct:
class CMyPropertySheet : public CPropertySheet
{
// ...
public:
virtual int DoModal();
protected:
static int CALLBACK PropSheetProc( HWND hwndDlg, UINT uMsg, LPARAM lParam );
}
class CMyDialogTemplate : public CDialogTemplate
{
friend CMyPropertySheet;
}
int CMyPropertySheet::DoModal()
{
m_psh.dwFlags |= PSH_USECALLBACK;
m_psh.pfnCallback = PropSheetProc;
return CPropertySheet::DoModal();
}
int CALLBACK CMyPropertySheet::PropSheetProc( HWND hwndDlg, UINT uMsg, LPARAM lParam )
{
switch ( uMsg )
{
case PSCB_PRECREATE:
{
LPDLGTEMPLATE pTemplate = ( LPDLGTEMPLATE )lParam;
CMyDialogTemplate dlgTemplate;
dlgTemplate.m_hTemplate = ::GlobalHandle( pTemplate );
dlgTemplate.m_dwTemplateSize = CMyDialogTemplate::GetTemplateSize( pTemplate );
dlgTemplate.SetFont( _T("Tahoma"), 8 );
dlgTemplate.Detach();
break;
}
default:
break;
}
return 0;
}
I am in doubt if it is allowed to modify property sheet template this way.
Although I have tried it out on NT4 and everything looked just fine.
Regards,
Nikolay
|
|
|
|
|
Small question... Why not use SetFont in the CPropertyPage-derived class(es)? You can use it in CPropertyPage::OnInitDialog(...). You can set the font for the dialog, and its controls right there.
-=- James.
|
|
|
|
|
Because I set the desired font for my CPropertyPages in the Resource Editor (although MFC ignores font settings for CPropertyPages in the Resource Editor , it could be easily solved by overriding CPropertySheet::BuildPropPageArray()), and at run-time, I want to set the sheet's FONT to be the same and SIZE everything correctly.
Unfortunately, the Windows Property Sheet control was designed so that it always uses the system font for the sheet. So the problem is that I need to specify somehow the desired font for the CPropertySheet itself. Above is my solution.
Regards,
Nikolay
|
|
|
|
|
Does anyone know how to create a property sheet then create it in a Dialog Bar (DIFFERENT THEN A DIALOG!) I've been have problems doing this in MFC. Thanks
|
|
|
|
|
I need a Blue Combobox with white text:
I have a new class CBlueComboBox derived from CComboBox. My combo is declared in my Ressource
as OwnerDraw, Fixed and has String.
In the new class I overwrite the DrawItem function:
void CBlueComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
ASSERT(lpDrawItemStruct->CtlType == ODT_COMBOBOX);
CDC dc;
CString strText;
GetLBText (lpDrawItemStruct->itemID,strText);
dc.Attach(lpDrawItemStruct->hDC);
COLORREF crOldTextColor = dc.GetTextColor();
COLORREF crOldBkColor = dc.GetBkColor();
if ((lpDrawItemStruct->itemAction | ODA_SELECT) &&
(lpDrawItemStruct->itemState & ODS_SELECTED))
{
dc.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
dc.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
dc.FillSolidRect(&lpDrawItemStruct->rcItem, ::GetSysColor(COLOR_HIGHLIGHT));
}
else
{
dc.SetTextColor(RGB(255,255,255));
dc.SetBkColor(RGB(41,66,148));
dc.FillSolidRect(&lpDrawItemStruct->rcItem,RGB(41,66,148));
}
dc.DrawText(strText, &lpDrawItemStruct->rcItem, DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER);
dc.SetTextColor(crOldTextColor);
dc.SetBkColor(crOldBkColor);
dc.Detach();
}
All is OK apart the text: Combo si blue, text is white
but the text is not written correctly, it is alway the same control caracter.
Could someone help me?
Thanks
Natacha
|
|
|
|
|
CString strText;
GetLBText (lpDrawItemStruct->itemID,strText);
should be
CString strText;
int len;
len = GetLBTextLen(lpDrawItemStruct->itemID);
GetLBText (lpDrawItemStruct->itemID,strText.GetBuffer(len));
strText.ReleaseBuffer();
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Just change "strText" by "(char*)((LPCSTR)lpDrawItemStruct->itemData)" when drawing the text.
My test is working. Good luck !
|
|
|
|
|
does anyone know how to determine whether windows requires a login or not.
i.e. need to know if a system is multi-user or not.
cheers
Neil
|
|
|
|
|
Using VC++ 6.0
I'm writing a DLL and it works fine from a C++ program. However, a friend of mine wants to use the DLL from a VB app.
My exported prototypes look like this:
extern "C" void FAR PASCAL EXPORT SR_GetString(char* sRunning);
typedef void (FAR PASCAL* LPFNsr_GetString)(char* sRunning);
I also have a .DEF file with this export line:
GetString @1
In my C++ program (that uses this DLL), I do this:
HMODULE hMyDLL = ::LoadLibrary("MyDLL.DLL");
LPFNsr_GetString m_fnSRGetString = GetProcAddress(hMyDLL, "SR_GetString");
char cText[255;
(m_fnSRGetString*)(cText);
I get the expected results (cText contains the expected string).
My Objective:
I want to make this DLL VB-friendly (*NOT* VB-specific) while having minimum impact on the code I've already written in both my C++ app and the DLL in question. I plan on requiring 32-bit VB in order to use the DLL, so the 16/32-bit concerns should be NULL.
If anyone can steer me, give me hints, tell me outright how to do it, etc, I'd be most appreciative.
Last thing, besides the DLL, what file(s) do I have to give the VB programmer who wants to use it?
|
|
|
|
|
i posted an answer to your jsimmons3@satr...... account
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
damn - i'm at work...
Could I convince you to post it here too?
|
|
|
|