Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I have been a grateful member of this site for several years. I love this site and refer everyone to it!..."

Geography

Where in the world do Tek-Tips members come from?

How to achieve concurrency with ODBC and MS Jet 4.0

ivoef (Programmer)
10 Sep 08 2:36
Hi,

I would like to know, how could I resolve the following problem:

I am using ODBC API a MS JET 4.0 driver (MS Access database). In the database there is a simple table with two columns called "Counter" and "IDRow". "IDRow" serves as ID for selecting an unique row.

I need to read and then immediately increment and store a value of the column "Counter" corectly when two or more independent processes are doing the same on this column.

Goal:

When one process reads, increments and stores the value of "Counter", no other process can update this column or the process should be aware of such change.

I have tried to use a cursor with SQL_CURSOR_KEYSET_DRIVEN and SQL_CONCUR_VALUES and SQLSetPos function the following way:

SQLAllocHandle(SQL_HANDLE_STMT, pstRPDBApi->hODBCConSys, &hSysStmt);
SQLSetStmtAttr(hSysStmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_KEYSET_DRIVEN, SQL_IS_UINTEGER);
SQLSetStmtAttr(hSysStmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_VALUES, SQL_IS_UINTEGER);
SQLBindCol(hSysStmt, 1, SQL_C_USHORT, &sunCounter, sizeof(sunIDRelaceNew);
SQLExecDirect(hSysStmt, "SELECT Counter FROM tabTest WHERE IDRow=1", SQL_NTS);
SQLFetch(hSysStmt);

At this point I change from outside the value of Counter at row where IDRow=1 and then continue with the following statement:

SQLSetPos(hSysStmt, 1, SQL_UPDATE, SQL_LOCK_NO_CHANGE);

According to the documentation (if I understood it) I should get an error because of changing the value of "Counter" between fetching and updating with cursor of this type. But there is no error and value is updatet with SQL_SUCCESS.

Could anybody help me with this problem please?

Ivo

 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close