Solved

Excel - check whether data added to a SQL database

Posted on 2011-09-11
2
210 Views
Last Modified: 2012-05-12
Hi

In VBA I have written code to add data to an Access database.
I have code that checks the highest ID before and after the Insert Statement
and if this has changed returns a successful entry.
With multiple users however, this might cause problems.
Should I maybe also use a select statement to see if that exact info is there?
0
Comment
Question by:murbro
2 Comments
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 36518433
If you cannot use an alternative like method I showed with SCOPE_IDENTITY(), then you may need to do something like that to be absolutely certain. For example, you may check for MAX(ID) and 100, then execute an insert that fails, but check for MAX(ID) again which returns 101 as another process successfully inserted a new row. As an alternative, you could run a scalar query that tests EXISTS() or COUNT() ... WHERE based on your criteria; however, if the insert failed because there was already a row with your new data then this method may also be flawed.

You may have to use a stored procedure to do inserts where you can return true or false to indicate success or failure.
0
 

Author Closing Comment

by:murbro
ID: 36518880
Thanks very much
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel Formula 5 43
Sql Server group by 10 26
sql how to count case when 4 14
Rather Simple Formatting Question 6 23
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question