|
Hi,
I have an MDI application. Suppose the user starts searching for something on one view. Then he/she switches over to another view. Obisouly, since the find dialog was launched with the other view, it won't be associated with the new one. But what if I wanted this to be the case? how do I make a find dialog launched in one view, to be associated with another view whenever the second view becomes active?
thanks
|
|
|
|
|
The dialog communicates with the application using Windows Messages. Define the message handlers on the level of views, then the messages from the search dialog will be received by the current top view.
Sonork 100.15206;PavelK
|
|
|
|
|
I am trying to add records using INSERT INTO
pCommand->CommandText="INSERT INTO tblTest (Color, Texture) VALUES ('navy blue', 'rusty') ";
_RecordsetPtr pRecordset;
hr = pRecordset.CreateInstance (__uuidof (Recordset));
if (FAILED (hr))
{
AfxMessageBox ("Can't create an instance of Recordset");
return;
}
AfxMessageBox("LLL");
pRecordset->CursorLocation = adUseClient;
pRecordset->Open ((IDispatch *) pCommand, vtMissing, adOpenDynamic, adLockBatchOptimistic, adCmdTable);
i get an exception at the Open statement so theres something it doesnt like about the SQL i guess.
ANy ideas wil be appreciated!
Thanks,
ns
|
|
|
|
|
Just out of curosity, since this is an insert, why would you use a recordset for? Try using ExecuteSQL on the connection object.
Also, make sure that pRecordset is not 0 when you are calling the open.
|
|
|
|
|
Heres what I tried: stil exception on execute
LPCTSTR lpstrExec ="INSERT INTO tblTest VALUES ('navy blue', 'rusty','aa,'aa,'aa,'aa') ";
m_pConn->CursorLocation = adUseClient;
m_pConn->Execute(_bstr_t(lpstrExec), NULL, adExecuteNoRecords);
Of course I'm justguessing...new at this stuff.
Thank you so much for replying,
ns
|
|
|
|
|
Your latest SQL statement is incorrect btw...the first one was ok.in this one you're missing your column names..You either have to go insert into x(yy,yyy,yyy) values ('','','') or insert into x select x,x,x
This usually works for me as far as inserts go. Remember that you are dealing with COM, so everything is _bstr_t..so you can't just use strings...
Here m_pConnection and varQuery are defined as
const std::string & varQuery
static _Connection * m_pConnection;
then here is my functin which receives the varQuery...BTW, for USES_CONVERSION, you need to include atlconv.h file!
BOOL CDBClass::ExecuteQuery(const std::string & szQuery)
{
USES_CONVERSION;
BOOL bRet = TRUE;
HRESULT hRes = 0;
_variant_t varQuery;
varQuery = A2W(szQuery.c_str());
if(m_pConnection == 0)
CreateConnection();
if(m_pConnection != 0)
{
try {
hRes = m_pConnection->Execute(varQuery.bstrVal, NULL, NULL, NULL);
}
catch (...)
{
bRet = FALSE;
}
if(hRes != 0)
GetError();
hRes == 0 ? bRet = 1 : bRet = 0;
}
return bRet;
}
|
|
|
|
|
Also tried:(exception again)
pCommand->CommandText="INSERT INTO tblTest VALUES ('navy blue', 'rusty','aa,'aa,'aa,'aa') m_pConn->CursorLocation = adUseClient;
m_pCmd->ActiveConnection = mpdb;
m_pCmd->CommandText = _bstr_t(m_strQuery);
m_pCmd->CommandType = adCmdStoredProc;
m_pConnection->CursorLocation = adUseClient;
_RecordsetPtr pRecordset;
hr = pRecordset.CreateInstance (__uuidof (Recordset));
if (FAILED (hr))
{
AfxMessageBox ("Can't create an instance of Recordset");
return;
}
pRecordset= m_pCmd->Execute(NULL, NULL, adCmdText);
|
|
|
|
|
Hi,
I'm almost done with a card game I'm writting, when all of a sudden my program wont exit. I learned (by accident) that everytime I click the 'x' (exit button), it is calling a function I wrote. I never told it to do this!
I'm not sure why its doing this, but is there a way to override the 'x' menu exiting and add my own OnOK() code? Or is this a normal, simple (easy to fix) problem?
Thanks in advance,
~ Selevercin
If you have a problem with my spelling, just remember that's not my fault. I [as well as everyone
else who learned to spell after 1976] blame it on
Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
|
No, I'm not overriding WM_CLOSE, altough I just tried it. I was able to confirm that when I attempt to close the program, it is being called, yet it is not closing my app.
Any suggestions?
If you have a problem with my spelling, just remember that's not my fault. I [as well as everyone
else who learned to spell after 1976] blame it on
Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
For a recordset, GetAbsolutePosition works and gives you back the posn of the record. If I want to place myself at record # 3 say, then there doesnt seem to be a corresponding SetAbsolutePosition....?
What can I use?
Thanks,
ns
|
|
|
|
|
A CP class thats not flexible enough for me had the tip in it though. Its weird how one can force an integer to be
pRecordset->PutAbsolutePosition((PositionEnum)3);
even though in msado15.tlh it says:
enum PositionEnum
{
adPosUnknown = -1,
adPosBOF = -2,
adPosEOF = -3
};
I didnt think you could force any old value to belong to the enum when its not even defined in it.
Very puzzled:
|
|
|
|
|
It maybe because of the enum. Well, its positioning me at records that are not anywhere near what I think they should be. INcrementing by one jumps me by several records. Helllppp!
I need to position myself in the set of records referenced by a local index (if 5 were returned, then 0-4 or something...)
Thanks,
ns
|
|
|
|
|
I tried the following which obviously has a flaw:
{
_CommandPtr pCommand;
HRESULT hr = pCommand.CreateInstance (__uuidof (Command));
if (FAILED (hr))
{
AfxMessageBox ("Can't create an instance of Command");
return;
}
pCommand->ActiveConnection = m_pConn;
pCommand->CommandText="SELECT * FROM tblTest ";
_RecordsetPtr pRecordset;
hr = pRecordset.CreateInstance (__uuidof (Recordset));
if (FAILED (hr))
{
AfxMessageBox ("Can't create an instance of Recordset");
return;
}
pRecordset->CursorLocation = adUseClient;
pRecordset->Open ((IDispatch *) pCommand, vtMissing, adOpenStatic,
adLockBatchOptimistic, adCmdUnknown);
CString strContent;
CString numRec;
long num =pRecordset->RecordCount;
numRec.Format("number of records is %d ",num);
AfxMessageBox(numRec);
pRecordset->AddNew();
pRecordset->Fields->GetItem("Color")->Value = "orange";
pRecordset->Fields->GetItem("Texture")->Value = "fuzzy";
pRecordset->UpdateBatch (adAffectAll);
pRecordset->Close ();
}
I feel I'm not telling it where to add. Besides a lot of fields for the record I want to add are not included, just color and texture. ANy clues as to what I need to do to get AddNew to work?
Thanks,
ns
|
|
|
|
|
ns wrote:
pRecordset->UpdateBatch (adAffectAll);
?
Have you tried pRecordset->UpdateBatch (adAffectCurrent);
And which record are you at ?
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining.
Said by Roger Wright about me.
|
|
|
|
|
The literature I read said it appends at the end of the rs so you dont have to PutAbsolutePosition(index) to place it at the end. I tried putting it at adEOF but still no results.
Thanks and I will try your suggestion,
ns
|
|
|
|
|
Hey Guys
How do i get global variables available in all files of project. For instance i declare a global variable in a header and then include that header in everything that i want to acces the global variable but that doesn't work so how exactly do i go about doing it so i can have a program wide global accesable from any cpp file.
Peter
|
|
|
|
|
Define the variables above the main () in your main.cpp source. Declare the variables as "extern" in your other header files. Done.
|
|
|
|
|
Cheers Works buetifully
Peter
|
|
|
|
|
I get the error - current recordset dose not support updating. Ths may be due to the lockType. I have a recordset object (from a CP class) and its constructed as
CADORecordset::CADORecordset(CADODatabase* pAdoDatabase)
{
m_pRecordset = NULL;
m_pCmd = NULL;
m_strQuery = _T("");
m_pRecordset.CreateInstance(__uuidof(Recordset));
m_pCmd.CreateInstance(__uuidof(Command));
m_nEditStatus = CADORecordset::dbEditNone;
m_nSearchDirection = CADORecordset::searchForward;
m_pConnection = pAdoDatabase->GetActiveConnection();
}
with
_RecordsetPtr m_pRecordset;
How can I set the lockType and to what should I set it?
Thanks ,
ns
ANother question:
You can see that the search direction above is forward, and each time I search I want to strat from the beginning. How would I accomplish that?
|
|
|
|
|
|
You get it from command line using
nbtstat -A "IP_address"
Thanks,
Satish
|
|
|
|
|
What name do you want?
The "internal" netbios name, like "server", or the dns-name, like "codeproject.com"
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
see documentation for gethostbyaddr() in MSDN. Maybe that'll help.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I tried many source corders, did not find a worked sample for gethostbyaddr().
|
|
|
|