Solved

Excel - check whether data added to a SQL database

Posted on 2011-09-11
2
209 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now