Preventing duplicate records been written to an SQL Database - InfoPath Dev
in

InfoPath Dev

Preventing duplicate records been written to an SQL Database

Last post 03-25-2010 10:14 PM by Patrick Halstead. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-24-2010 04:30 PM

    Preventing duplicate records been written to an SQL Database

    Hi there, I could use some assistance. I have created a timesheet in InfoPath that writes to a MSSQL database. I want to prevent duplicate timesheets being written. Essentially there are two fileds (1) Employee ID and (2) Start Date that identify unique timesheets.

    I need to check if there is an existing record that matches these two fields, and if so I want to prevent the user from creating a new timesheet. Anyone have any experience with this?

    I expect I need to query either in VB code (having troubles finding good examples) or directly on the form. But I find that doing a query after initiating 'new record' causes some problems. Any help or direction would be good :)

    Thanks,

     Andrew 

     

    Filed under:
  • 03-25-2010 10:14 PM In reply to

    Re: Preventing duplicate records been written to an SQL Database

    Hi Andrew and welcome,

    I just responded to another thread and explained why having a tight coupling to SQL is a bad idea. Check it out: http://www.infopathdev.com/forums/t/14967.aspx

    Probably the easiest thing for you to do is to just query the table and see if the ID exists and if it does, hide the button that submits. You don't need to write code in the form to do this if you use a Web Service. Form-based coding is a bad practice because of the higher costs when you have to maintain that code across many different XSNs. You could write a simple Web Service that takes an ID parameter and queries your table and returns true or false and then use that to set conditional visibility for your button to "disable" it if the return is true. Easy to do. Or, if you don't want to code, you could install Qdabra's free DBXL trial and setup the query in 10-15 minutes.

    Happy trails!

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.