|
Hi all,
I am new in MFC.
I am struggling with one of my system's modules which is I need to edit filed's value in the data source depending on some variables.
My problem is I stuck with Recordset type because I making the editting via SQL statment and the following which are I done so far:
CDatabase DBDecaying;
CString SqlRulesDecaying;
CString sDriver("MICROSOFT ACCESS DRIVER (*.mdb)");
CString sDsn;
CString ssDSN("ODBC;DRIVER={%s};DSN='';DBQ=%s");
CString sFile("c:\\DB\\db.mdb");
sDsn.Format(ssDSN, sDriver, sFile);
DBDecaying.Open(NULL,false,false,sDsn);
CRecordset RecSetRulesDecaying( &DBDecaying );
int X=2,Y=3;
double NewActiLevel = 0;
SqlRulesDecaying.Format(_T("update Rules set RActiLevel=%f where CNum=%d and
RNum=%d"),NewActiLevel,X,Y);
RecSetRulesDecaying.Open(CRecordset::forwardOnly,SqlRulesDecaying,CRecordset::??????);
Regarding the first parameter I tried snapshot,dynaset and dynamic instead of forwardonly. nothing happens.
So what I should put insted of ???? I tried (Update,Can Update,..) but I had syntax errors.
So please any help will be appreciated.
Best regards.
|
|
|
|
|
moh.hijjawi wrote: Regarding the first parameter I tried snapshot,dynaset and dynamic instead of forwardonly. nothing happens.
Since CRecordset::forwardOnly is a read-only recordset, that would be the one to not choose. Any of the others should work.
moh.hijjawi wrote: So what I should put insted of ????
CRecordset::none should be sufficient.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
First of all thank you.
I did like you mentioned but i have an error which is "Attempt to open a table failed- there is no columns to retrieve were specified" and I sure that the sql it is OK;
please any help
|
|
|
|
|
Have you tried:
CString sDriver("MICROSOFT ACCESS DRIVER (*.mdb)");
CString ssDSN("ODBC;DRIVER={%s};DSN='';DBQ=%s");
CString sFile("c:\\DB\\db.mdb");
CString sDsn;
sDsn.Format(ssDSN, sDriver, sFile);
int X=2,Y=3;
double NewActiLevel = 0;
CString SqlRulesDecaying;
SqlRulesDecaying.Format(_T("update Rules set RActiLevel=%f where CNum=%d and RNum=%d"),NewActiLevel,X,Y);
CDatabase DBDecaying;
DBDecaying.Open(NULL,false,false,sDsn);
DBDecaying.ExecuteSQL(SqlRulesDecaying);
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Now it works fine. so there is no need for recordset statement.
Thank you very much indeed
|
|
|
|
|
Hi all,
I have a Report style list control an i want to search an item inside that list control using Find function.
My problem is i want to search that item in second column.
LVFINDINFO info;
int nIndex = 0;
info.flags = LVFI_STRING;
info.psz = FirstRun;
while ((nIndex = g_index->FindItem(&info)) != -1)
{
g_index->DeleteItem(nIndex);
}
This code searches value in first column only.
How can i do this...
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
How about:
for (int x = 0; x < g_index.ItemCount(); x++)
{
CString strText = g_index.GetItemText(x, col);
if (strText == FirstRun)
{
g_index->DeleteItem(x);
break;
}
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
The following code genarates C4389 warning.
How to remove this?
int main()
{
int a = 9;
unsigned int b = 10;
if (a == b) // C4389
return 0;
else
return 0;
};
|
|
|
|
|
use
unsigned int a = 9;
unsigned int b = 10;
or
int a = 9;
int b = 10;
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
#pragma warning( disable : 4389 )
|
|
|
|
|
Hi
i want to set BG color for DoModal Dialogs .
can any one suggest me...
i.e i have 2 dialogs , say dg1,dg2.
when i click a button in dg1, dg2 dialog appears.i need to set the bg for dg2...
Thanks in advance
Regards
Gany
|
|
|
|
|
Hope this helps.
[EDIT]
Here is another sample how to change MFC common dialog BG color.
Life is a stage and we are all actors!
modified on Friday, October 9, 2009 6:35 AM
|
|
|
|
|
Override the
HBRUSH CXDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
and return a suitable colour brush which will be used for BG color of the dialog.
Anish C.V
http://www.iedetech.com
|
|
|
|
|
|
|
|
What are you trying to do? Do you want to find, given two strings, a common subtring?
Please elaborate.
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,
Hope this question is relevant to this forum. Would like to know how to set a break point in kdbg in a .cpp file that is not in the same directory as the exe (such that I cannot see the source code in the debugger where I wish to set the breakpoint).
Thanks for any information.
|
|
|
|
|
Hello ALL,
In one of my applications running under local user account, I need to spawn a process internally from system account.I was using OpenProcessToken () and was trying to collect token of winlogon.exe running under system account and was specifying flag as TOKEN_ALL_ACCESS but this fails.
Also if I specify the FLAG as TOKEN_QUERY then I get the handle but then trying to CreateProcesswithUser resulted in Error "Access is denied". Can some body suggest me a solution through which I can spawn a new process through SYSTEM account when my process itself is running through a user account .
Regards,
Kushagra
I hate to code but I luv to develop
modified on Friday, October 9, 2009 3:29 AM
|
|
|
|
|
Kushagra Tiwari wrote: I was using OpenProcessToken () and was trying to collect token of winlogon.exe running under system account and was specifying flag as TOKEN_ALL_ACCESS but this fails.
The API documentation states that you could call GetLastError()[^] to get extended information on the reason for failure. Have you tried that?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I got "Access is denied" (using getlasterror())error while trying to call openprocesstoken as I already mentioned. But some how I want to spawn a process through system account while my base process is running under user account.
Kushagra
|
|
|
|
|
Hi all,
i have a excel files,
i want to divide into known number of small files.
for example::
if original excel file have 10000 rows,and we want to divide it in 6 parts.
its means create 6 files those have 10000/6 row in each file.
but the serial of copying data in small file not according to serial it must be on random basis.
means 10000/6==1666.67
any 1666 row of original file write in any other excel file.
please tell me how can i do this.
if possible please provide me any example.
thanks in advance.
|
|
|
|
|
|
Useless.
Simply copy one of the numerous Microsoft COM samples to parse Excel files
|
|
|
|
|
It isn't "useless". Someone has put their efforts into it.
If you have something "useful" to say, say it to the OP by replying to his message.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|