Using OLEDB, Jet 4.0, C++, Windows.
I have been baffled by UPDATE queries that return S_OK but do not change the
data in the database. It seems that UPDATEs do not update until the
CDataSource object goes out of scope, in some cases, they seem not to update
at all. Apparently the data is being cached and transmitted through some
kind of flushing mechanism.
I would like to "force" writes of data after executing an UPDATE query
through a CCommand<> derived object.
How do I do this?
Some code is posted below.
class CNumberCommandA ccessor
{
public:
LONG m_ID;
DATE m_Num0;
BEGIN_PARAM_MAP (CNumberCommand Accessor)
COLUMN_ENTRY_TY PE(1, DBTYPE_DATE, m_Num0)
COLUMN_ENTRY(2, m_ID)
END_PARAM_MAP()
DEFINE_COMMAND_ EX(CNumberComma ndAccessor, L"\
UPDATE Table2 \
SET Table2.Num0 = (?) \
WHERE Table2.ID =(?)")
};
int wmain(int argc, wchar_t * argv[])
{
CoInitialize(0) ;
{
CComPtr<IDataCo nvert> pCvt = 0;
HRESULT hr = CoCreateInstanc e(CLSID_OLEDB_C ONVERSIONLIBRAR Y, 0,
CLSCTX_INPROC_S ERVER | CLSCTX_LOCAL_SE RVER, IID_IDataConver t, (void
**)&pCvt);
if(FAILED(hr))
return 0;
CSession session;
CDataSource db;
CDBPropSet dbinit[1];
dbinit[0].SetGUID(DBPROP SET_DBINIT);
dbinit[0].AddProperty(DB PROP_AUTH_USERI D, OLESTR("Admin") );
dbinit[0].AddProperty(DB PROP_INIT_DATAS OURCE, sDBFile);
dbinit[0].AddProperty(DB PROP_INIT_MODE, (long)16);
dbinit[0].AddProperty(DB PROP_INIT_PROMP T, (short)DBPROMPT _NOPROMPT);
if(Open(session , db, dbinit, 1))
{
//CTable<CAccesso r<CDateAccessor > > d;
CCommand<CAcces sor<CNumberComm andAccessor> > d;
CDBPropSet propset(DBPROPS ET_ROWSET);
propset.AddProp erty(DBPROP_IRo wsetChange, true);
propset.AddProp erty(DBPROP_IRo wsetUpdate, true);
propset.AddProp erty(DBPROP_UPD ATABILITY, DBPROPVAL_UP_CH ANGE |
DBPROPVAL_UP_IN SERT | DBPROPVAL_UP_DE LETE);
/*
We have a record #6, yes ...
*/
d.m_ID = 6;
d.m_Num0 = SOME_NEW_INTEGE R_VALUE;
HRESULT hr = d.Open(session) ; //I EXPECT to see the changes right after this
executes but don't
if(FAILED(hr))
{
Close(session, db);
return 0;
}
d.Close();
session.Commit( );
Close(session, db);
//STILL NO CHANGES
}
//NOW THEY APPEAR - WHY NOW?
}
CoUninitialize( );
return 0;
} 3 3551
On Sat, 20 Aug 2005 15:55:39 -0700, "Riley DeWiley"
<ri***********@ gmail.com> wrote:
I have no specific knowledge about CCommand, but isn't there an
Execute method? Open seems more for recordset-returning commands
(SELECT statements), whereas Execute is typically used for action
queries like UPDATE, DELETE etc.
Your code reminds me why I don't program in C++ anymore. I've lost
appetite for accomplishing simple tasks with many lines of code.
-Tom. Using OLEDB, Jet 4.0, C++, Windows.
I have been baffled by UPDATE queries that return S_OK but do not change the data in the database. It seems that UPDATEs do not update until the CDataSource object goes out of scope, in some cases, they seem not to update at all. Apparently the data is being cached and transmitted through some kind of flushing mechanism.
I would like to "force" writes of data after executing an UPDATE query through a CCommand<> derived object.
How do I do this?
Some code is posted below.
class CNumberCommandA ccessor
{
public:
LONG m_ID;
DATE m_Num0;
BEGIN_PARAM_MA P(CNumberComman dAccessor)
COLUMN_ENTRY_T YPE(1, DBTYPE_DATE, m_Num0)
COLUMN_ENTRY(2 , m_ID)
END_PARAM_MAP( )
DEFINE_COMMAND _EX(CNumberComm andAccessor, L"\
UPDATE Table2 \
SET Table2.Num0 = (?) \
WHERE Table2.ID =(?)")
}; int wmain(int argc, wchar_t * argv[])
{
CoInitialize(0 );
{
CComPtr<IDataC onvert> pCvt = 0;
HRESULT hr = CoCreateInstanc e(CLSID_OLEDB_C ONVERSIONLIBRAR Y, 0, CLSCTX_INPROC_ SERVER | CLSCTX_LOCAL_SE RVER, IID_IDataConver t, (void **)&pCvt);
if(FAILED(hr ))
return 0;
CSession session;
CDataSource db;
CDBPropSet dbinit[1];
dbinit[0].SetGUID(DBPROP SET_DBINIT);
dbinit[0].AddProperty(DB PROP_AUTH_USERI D, OLESTR("Admin") );
dbinit[0].AddProperty(DB PROP_INIT_DATAS OURCE, sDBFile);
dbinit[0].AddProperty(DB PROP_INIT_MODE, (long)16);
dbinit[0].AddProperty(DB PROP_INIT_PROMP T, (short)DBPROMPT _NOPROMPT);
if(Open(sessio n, db, dbinit, 1))
{
//CTable<CAccesso r<CDateAccessor > > d;
CCommand<CAcce ssor<CNumberCom mandAccessor> > d;
CDBPropSet propset(DBPROPS ET_ROWSET);
propset.AddPro perty(DBPROP_IR owsetChange, true);
propset.AddPro perty(DBPROP_IR owsetUpdate, true);
propset.AddPro perty(DBPROP_UP DATABILITY, DBPROPVAL_UP_CH ANGE | DBPROPVAL_UP_I NSERT | DBPROPVAL_UP_DE LETE);
/*
We have a record #6, yes ...
*/
d.m_ID = 6;
d.m_Num0 = SOME_NEW_INTEGE R_VALUE;
HRESULT hr = d.Open(session) ; //I EXPECT to see the changes right after this executes but don't
if(FAILED(hr ))
{
Close(sessio n, db);
return 0;
}
d.Close();
session.Commit ();
Close(sessio n, db);
//STILL NO CHANGES
}
//NOW THEY APPEAR - WHY NOW?
}
CoUninitialize ();
return 0;
}
Yes, this is how the Jet driver works. Data modifications are
asynchronously flushed to the database file.
You have to do some special things to bypass this asynch behavior, I'm
digging around but I can't find anything to help you here. I wrote a KB
article about 5-6 years ago about this but it looks like they deleted it.
Matt Neerincx [MSFT]
This posting is provided "AS IS", with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
"Riley DeWiley" <ri***********@ gmail.com> wrote in message
news:CN******** ************@se anet.com... Using OLEDB, Jet 4.0, C++, Windows.
I have been baffled by UPDATE queries that return S_OK but do not change the data in the database. It seems that UPDATEs do not update until the CDataSource object goes out of scope, in some cases, they seem not to update at all. Apparently the data is being cached and transmitted through some kind of flushing mechanism.
I would like to "force" writes of data after executing an UPDATE query through a CCommand<> derived object.
How do I do this?
Some code is posted below.
class CNumberCommandA ccessor
{
public:
LONG m_ID;
DATE m_Num0;
BEGIN_PARAM_MAP (CNumberCommand Accessor)
COLUMN_ENTRY_TY PE(1, DBTYPE_DATE, m_Num0)
COLUMN_ENTRY(2, m_ID)
END_PARAM_MAP()
DEFINE_COMMAND_ EX(CNumberComma ndAccessor, L"\
UPDATE Table2 \
SET Table2.Num0 = (?) \
WHERE Table2.ID =(?)")
}; int wmain(int argc, wchar_t * argv[])
{
CoInitialize(0) ;
{
CComPtr<IDataCo nvert> pCvt = 0;
HRESULT hr = CoCreateInstanc e(CLSID_OLEDB_C ONVERSIONLIBRAR Y, 0, CLSCTX_INPROC_S ERVER | CLSCTX_LOCAL_SE RVER, IID_IDataConver t, (void **)&pCvt);
if(FAILED(hr))
return 0;
CSession session;
CDataSource db;
CDBPropSet dbinit[1];
dbinit[0].SetGUID(DBPROP SET_DBINIT);
dbinit[0].AddProperty(DB PROP_AUTH_USERI D, OLESTR("Admin") );
dbinit[0].AddProperty(DB PROP_INIT_DATAS OURCE, sDBFile);
dbinit[0].AddProperty(DB PROP_INIT_MODE, (long)16);
dbinit[0].AddProperty(DB PROP_INIT_PROMP T, (short)DBPROMPT _NOPROMPT);
if(Open(session , db, dbinit, 1))
{
//CTable<CAccesso r<CDateAccessor > > d;
CCommand<CAcces sor<CNumberComm andAccessor> > d;
CDBPropSet propset(DBPROPS ET_ROWSET);
propset.AddProp erty(DBPROP_IRo wsetChange, true);
propset.AddProp erty(DBPROP_IRo wsetUpdate, true);
propset.AddProp erty(DBPROP_UPD ATABILITY, DBPROPVAL_UP_CH ANGE | DBPROPVAL_UP_IN SERT | DBPROPVAL_UP_DE LETE);
/*
We have a record #6, yes ...
*/
d.m_ID = 6;
d.m_Num0 = SOME_NEW_INTEGE R_VALUE;
HRESULT hr = d.Open(session) ; //I EXPECT to see the changes right after this executes but don't
if(FAILED(hr))
{
Close(session, db);
return 0;
}
d.Close();
session.Commit( );
Close(session, db);
//STILL NO CHANGES
}
//NOW THEY APPEAR - WHY NOW?
}
CoUninitialize( );
return 0;
}
Ok, found it ->
I wrote this KB eons ago, but it still applies.
"How To Synchronizing Reads and Writes Between Two DAO Processes" http://support.microsoft.com/kb/180223/EN-US/
Looks like the title was translated to some other language and back and
suffered in the process but the KB has all the info you need.
Matt Neerincx [MSFT]
This posting is provided "AS IS", with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
"Matt Neerincx [MS]" <ma***@online.m icrosoft.com> wrote in message
news:O9******** ******@TK2MSFTN GP09.phx.gbl... Yes, this is how the Jet driver works. Data modifications are asynchronously flushed to the database file. You have to do some special things to bypass this asynch behavior, I'm digging around but I can't find anything to help you here. I wrote a KB article about 5-6 years ago about this but it looks like they deleted it.
Matt Neerincx [MSFT]
This posting is provided "AS IS", with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup purposes only.
"Riley DeWiley" <ri***********@ gmail.com> wrote in message news:CN******** ************@se anet.com... Using OLEDB, Jet 4.0, C++, Windows.
I have been baffled by UPDATE queries that return S_OK but do not change the data in the database. It seems that UPDATEs do not update until the CDataSource object goes out of scope, in some cases, they seem not to update at all. Apparently the data is being cached and transmitted through some kind of flushing mechanism.
I would like to "force" writes of data after executing an UPDATE query through a CCommand<> derived object.
How do I do this?
Some code is posted below.
class CNumberCommandA ccessor
{
public:
LONG m_ID;
DATE m_Num0;
BEGIN_PARAM_MAP (CNumberCommand Accessor)
COLUMN_ENTRY_TY PE(1, DBTYPE_DATE, m_Num0)
COLUMN_ENTRY(2, m_ID)
END_PARAM_MAP()
DEFINE_COMMAND_ EX(CNumberComma ndAccessor, L"\
UPDATE Table2 \
SET Table2.Num0 = (?) \
WHERE Table2.ID =(?)")
}; int wmain(int argc, wchar_t * argv[])
{
CoInitialize(0) ;
{
CComPtr<IDataCo nvert> pCvt = 0;
HRESULT hr = CoCreateInstanc e(CLSID_OLEDB_C ONVERSIONLIBRAR Y, 0, CLSCTX_INPROC_S ERVER | CLSCTX_LOCAL_SE RVER, IID_IDataConver t, (void **)&pCvt);
if(FAILED(hr))
return 0;
CSession session;
CDataSource db;
CDBPropSet dbinit[1];
dbinit[0].SetGUID(DBPROP SET_DBINIT);
dbinit[0].AddProperty(DB PROP_AUTH_USERI D, OLESTR("Admin") );
dbinit[0].AddProperty(DB PROP_INIT_DATAS OURCE, sDBFile);
dbinit[0].AddProperty(DB PROP_INIT_MODE, (long)16);
dbinit[0].AddProperty(DB PROP_INIT_PROMP T, (short)DBPROMPT _NOPROMPT);
if(Open(session , db, dbinit, 1))
{
//CTable<CAccesso r<CDateAccessor > > d;
CCommand<CAcces sor<CNumberComm andAccessor> > d;
CDBPropSet propset(DBPROPS ET_ROWSET);
propset.AddProp erty(DBPROP_IRo wsetChange, true);
propset.AddProp erty(DBPROP_IRo wsetUpdate, true);
propset.AddProp erty(DBPROP_UPD ATABILITY, DBPROPVAL_UP_CH ANGE | DBPROPVAL_UP_IN SERT | DBPROPVAL_UP_DE LETE);
/*
We have a record #6, yes ...
*/
d.m_ID = 6;
d.m_Num0 = SOME_NEW_INTEGE R_VALUE;
HRESULT hr = d.Open(session) ; //I EXPECT to see the changes right after this executes but don't
if(FAILED(hr))
{
Close(session, db);
return 0;
}
d.Close();
session.Commit( );
Close(session, db);
//STILL NO CHANGES
}
//NOW THEY APPEAR - WHY NOW?
}
CoUninitialize( );
return 0;
}
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mohammed Mazid |
last post by:
Can anyone please help me here? Basically I have modified the source
code and understood it but when I update a record in the db using a
JSP, it gives me an error "The flight you selected does exist."
Althought there is not selection going on, instead it is entered, I
need it to match the flight in the db using the flightNo. I want all
the attributes to be changed apart from the flightNo itself as it is
it's associated details I need...
|
by: Lauren Quantrell |
last post by:
In VBA, I constructed the following to update all records in
tblmyTable with each records in tblmyTableTEMP having the same
UniqueID:
UPDATE
tblMyTable RIGHT JOIN tblMyTableTEMP ON tblMyTable.UniqueID =
tblMyTableTEMP.UniqueID
SET
tblMyTable.myField = tblMyTableTEMP.myField,
tblMyTable.myField2 = tblMyTableTEMP.myField2,
|
by: kalamos |
last post by:
This statement fails
update ded_temp a
set a.balance = (select sum(b.ln_amt)
from ded_temp b
where a.cust_no = b.cust_no
and a.ded_type_cd = b.ded_type_cd
and a.chk_no = b.chk_no
group by cust_no, ded_type_cd, chk_no)
|
by: Dom Boyce |
last post by:
Hi
First up, I am using MS Access 2002.
I have a database which records analyst rating changes for a list of
companies on a daily basis. Unfortunately, the database has been set
up (by my predecessor, I hasten to add) so that each day it creates a
copy of the record for each company, changes the date to today's date,
and prompts the user for any changes of ratings on that day. The
resulting data table grows by approx 600 records per...
|
by: Maxi |
last post by:
There is a lotto system which picks 21 numbers every day out of 80
numbers.
I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21)
Here is the structure and sample data:
"Date","P1","P2","P3","P4","P5","P6","P7","P8","P9","P10","P11","P12","P13","P14","P15","P16","P17","P18","P19","P20","P21"
1/1/2005,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21
1/2/2005,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
| |
by: cover |
last post by:
I have an input form that passes data when submitted to a second form
to let the user know what they have just entered into the db.
My question comes with using 'update'. I'd like to query the database
by equipment number (equipno is unique) and query all fields from that
row, populating an original form 'look alike' whereby the user can add
detail to the original records as the db builds. I'm using 'date'
twice because I'd like to...
|
by: whitemoss |
last post by:
Hi,
I've made some changes to my coding..but unfortunately, there were errors when compiling it..dunno how to solve it..hope anyone can help me...the errors:
client.c: In function senddata:
client.c:147: error: incompatible implicit declaration of function UpdateStatus
client.c:37: error: previous implicit declaration of UpdateStatus was here
The code is as below:
|
by: P3Eddie |
last post by:
Hello all!
I don't know if this can even be done, but I'm sure you will either help or suggest another avenue to accomplish the same.
My problem may be a simple find duplicates / do something with only one of the duplicates issue, but I got to the point where an update query with a nested select subquery would work wonderfully, if only it would work!
I have several fields in a master Access 2000 table, some of which are id, fname,...
|
by: ARC |
last post by:
Hello all,
So I'm knee deep in this import utility program, and am coming up with all
sorts of "gotcha's!".
1st off. On a "Find Duplicates Query", does anyone have a good solution for
renaming the duplicate records? My thinking was to take the results of the
duplicate query, and somehow have it number each line where there is a
duplicate (tried a groups query, but "count" won't work), then do an update
query to change the duplicate to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |