×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to achieve concurrency with ODBC and MS Jet 4.0

How to achieve concurrency with ODBC and MS Jet 4.0

How to achieve concurrency with ODBC and MS Jet 4.0

(OP)
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

 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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! Already a Member? Login


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