Monday, March 12, 2012
ODBC ACCESS
this VIEWS in ACCESS inserting one key in runtime?
Posted using Wimdows.net NntpNews Component - Posted from SQL Servers Largest Community
Website: http://www.sqlJunkies.com/newsgroups/"domed" <darrigod@.-NOSPAM-tiscali.it> wrote in message
news:eo7FUPK9DHA.2480@.TK2MSFTNGP12.phx.gbl...
> I have a VIEW SQL connected to an other database. How I can connect
> this VIEWS in ACCESS inserting one key in runtime?
>
I'm not sure I understand your question... Any time you update data
programmatically, I'd recommend using a stored procedure, this you could
code to update tables in other database(s) if required.
Steve
Wednesday, March 7, 2012
Obtaining values on datasource inserting event
Hi,
I want to be able to spot when the same employee name gets added to my grid. This is to ensure that I cannot not have the same firstname and lastname (i.e. cannot have 2 John Smiths).
It is kind of like spoting for duplicates but they are not PKs. I was hoping if there was a way you could identify the the feild values on the "inserting" event of the datasource so I could put some logic in. The reason for placing it there is because we have the e.cancel = true command.
Thanks in advance,
Jon
Since you are going to have to query the database to get this information, why not just use If Not Exists in your SQL?
|||
Mike,
Thanks for getting back so promptly. I understand what you are saying what does the SQL look like ? would you be able to provide a very basic example?
Just to give you a little more background, I am using a mixture of standard ASP controls and also using the RAD controls. Currently I focus on the controls to perform this kind of checking and would like a more generic solution at the Datasource level, this is so I dont need to worry about specific coding based on which control I use.
Thanks
|||You would put it in a stored procedure:http://aspalliance.com/687_Preventing_Duplicate_Record_Insertion_on_Page_Refresh.5
Note: there are some other ideas in that article. You can review those as well.
Thanks, marked as answered
|||You can create a procedure like below and bind it as the insert command for your sql datasource. Then you can execute the insert method in a try catch block and display the error message to the user:
create procedure pcheckDuplicates_insert(@.firstNamevarchar(50) ,@.lastNamevarchar(50))asbeginifexists (select 1from checkDuplicateswhere firstName = @.firstNameand lastName = @.lastName )beginraiserror ('A person with this name already exists',16,1)with nowaitreturnendelsebegininsert checkDuplicates ( firstName , lastName )values ( @.firstName , @.lastName )endreturnend
I don't think you'll need that inserting event of the datasource. You can directly write all your duplicate prevention logic in the procedure itself.
Hope this will help.