Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / July 2007

Tip: Looking for answers? Try searching our database.

Submit to Web Service return value for insert operation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rick - 20 Jul 2007 16:38 GMT
I have a form that is using a web service to insert the form data into a
database. The inserted record has an auto-increment primary key value. After
the insert is performed I want to re-query the database using the primary key
of the record created during the submit process.

How do I get the primary key back to the form after submitting the form?
Paresh - 21 Jul 2007 01:28 GMT
> I have a form that is using a web service to insert the form data into a
> database. The inserted record has an auto-increment primary key value. After
> the insert is performed I want to re-query the database using the primary key
> of the record created during the submit process.
>
> How do I get the primary key back to the form after submitting the form?

Hi,

One way of doing this is to write a stored procedure that performs the
insert record operation and after that stored procedure, you can
return the generated primary key value using SCOPE_IDENTITY() method
of the SQL and collect this value in your web service.

Give this a though.  I guess this should help you out.  Still, if you
need any further assistance, do let me know.

Thanks,
Paresh
Paresh - 21 Jul 2007 09:52 GMT
> > I have a form that is using a web service to insert the form data into a
> > database. The inserted record has an auto-increment primary key value. After
[quoted text clipped - 15 lines]
> Thanks,
> Paresh

The stored procedure can be something like this:

CREATE PROCEDURE [dbo].[usp_InsertRecord]
    @Column1 int,
    @Column2 int,
    @Column3 int,
    @PrimKeyColumn int OUTPUT
AS

SET NOCOUNT ON

INSERT INTO [dbo].[Table1] (
    [Column1],
    [Column2],
    [Column3]
) VALUES (
    @Column1,
    @Column2,
    @Column3
)

SET @PrimKeyColumn = SCOPE_IDENTITY()

Also, you dont need to re-query the database.  The web service method
that you are writing to insert the record can be modified in such a
way that the same method collects the primary key value returned by
the stored procedure after insertion.

Hope this helps.

Thanks,
Paresh
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.