Click here to Skip to main content
15,907,149 members
Home / Discussions / Database
   

Database

 
Generalerror deleting record in datagrid Pin
Giovanni Bejarasco1-Oct-03 23:09
Giovanni Bejarasco1-Oct-03 23:09 
GeneralRe: error deleting record in datagrid Pin
Mike Dimmick2-Oct-03 12:18
Mike Dimmick2-Oct-03 12:18 
GeneralRe: error deleting record in datagrid Pin
Giovanni Bejarasco2-Oct-03 20:07
Giovanni Bejarasco2-Oct-03 20:07 
GeneralRe: error deleting record in datagrid Pin
Mike Dimmick2-Oct-03 22:30
Mike Dimmick2-Oct-03 22:30 
GeneralRe: error deleting record in datagrid Pin
Giovanni Bejarasco3-Oct-03 1:41
Giovanni Bejarasco3-Oct-03 1:41 
GeneralRe: error deleting record in datagrid Pin
Ian Darling3-Oct-03 22:16
Ian Darling3-Oct-03 22:16 
GeneralDatabases concurrecny issues Pin
Jahangir Jamshed1-Oct-03 19:26
sussJahangir Jamshed1-Oct-03 19:26 
GeneralRe: Databases concurrecny issues Pin
Andy Harman1-Oct-03 22:51
Andy Harman1-Oct-03 22:51 
Try searching the MSDN website for "optimistic locking".

On the system I have just developed, we have a "VersionNo" column. Whenever we retreive a resultset that may be modified by the user, we include this column in the column-list.

When we update the SQL-Server database we use stored-procedures that contain:
UPDATE SomeTable SET
    SomeColumn = @SomeValue,
    VersionNo = CASE WHEN VersionNo > 32000 THEN 1 ELSE VersionNo + 1 END,
    LastUpdateUser = @UserId,
    LastUpdateDate = GetDate()
  WHERE SomeKeyColumn = @SomeKeyValue
  AND VersionNo = @OriginalVersionNo
SELECT @intError = @@ERROR, @intRowCount = @@ROWCOUNT
IF @intRowCount <> 1 BEGIN
   RAISERROR('Concurrency problem - someone else has updated record', 16, 1)
   RETURN 1
END
This "VersionNo" value is incremented each time that we update the database. If the number of rows updated (@intRowCount) is not one then someone else has updated your record after you selected it. The case-statement stops the version-number from exceeding the size of the field (smallint in this case).

You can use similar code for Oracle and MS-Access databases - and you don't need to be using stored procedures (although it means that your concurrency control is isolated in a single place in your code).

Hope this helps.
Andy
GeneralRe: Databases concurrecny issues Pin
Mike Dimmick2-Oct-03 3:37
Mike Dimmick2-Oct-03 3:37 
GeneralRe: Databases concurrecny issues Pin
SimonS2-Oct-03 22:46
SimonS2-Oct-03 22:46 
GeneralDataRowState Problems Pin
Wjousts1-Oct-03 11:33
Wjousts1-Oct-03 11:33 
GeneralRe: DataRowState Problems Pin
Giovanni Bejarasco3-Oct-03 1:46
Giovanni Bejarasco3-Oct-03 1:46 
QuestionIndexing Problem??? Pin
Jason Weibel1-Oct-03 8:32
Jason Weibel1-Oct-03 8:32 
AnswerRe: Indexing Problem??? Pin
andyharman1-Oct-03 12:01
professionalandyharman1-Oct-03 12:01 
GeneralRe: Indexing Problem??? Pin
Jason Weibel2-Oct-03 12:09
Jason Weibel2-Oct-03 12:09 
GeneralRe: Indexing Problem??? Pin
Mike Dimmick2-Oct-03 12:49
Mike Dimmick2-Oct-03 12:49 
GeneralRe: Indexing Problem??? Pin
Jason Weibel3-Oct-03 6:08
Jason Weibel3-Oct-03 6:08 
GeneralRe: Indexing Problem??? Pin
Mike Dimmick3-Oct-03 6:27
Mike Dimmick3-Oct-03 6:27 
GeneralRe: Indexing Problem??? Pin
Jason Weibel3-Oct-03 6:44
Jason Weibel3-Oct-03 6:44 
GeneralDatabase documentation tools Pin
Michael P Butler1-Oct-03 7:19
Michael P Butler1-Oct-03 7:19 
GeneralRe: Database documentation tools Pin
Mike Dimmick2-Oct-03 3:49
Mike Dimmick2-Oct-03 3:49 
GeneralRe: Database documentation tools Pin
Michael P Butler2-Oct-03 22:47
Michael P Butler2-Oct-03 22:47 
GeneralConvert Access97 to 2000 programmatically Pin
Hans-Georg Ulrich1-Oct-03 5:37
Hans-Georg Ulrich1-Oct-03 5:37 
GeneralRe: Convert Access97 to 2000 programmatically Pin
Mike Ellison2-Oct-03 10:16
Mike Ellison2-Oct-03 10:16 
Generalerror in class type Pin
ranjjj1-Oct-03 5:02
ranjjj1-Oct-03 5:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.