Delete record from sql server database - InfoPath Dev
in

InfoPath Dev

Delete record from sql server database

Last post 11-26-2010 05:55 AM by goof1985. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 11-26-2010 05:55 AM

    Delete record from sql server database

    Hi all,

    I have a form in Infopath 2010 to perform some CRUD operations on a table in my sql server database. For all operations I have a stored procedure that's been called when I push on the corresponding button. Create en update just works perfect! Only my delete operation is not..

    Below my code:

    Public Sub btnDeleteSubject_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

    Dim dom As XPathNavigator = MainDataSource.CreateNavigator()

    Dim subjectStringID As String = dom.SelectSingleNode("//my:txtSubjectID", NamespaceManager).Value

    ' Retrieve the connection to the database table

    Dim connection As AdoQueryConnection = DataConnections("SubjectConnection")

    ' Save the original statement that is stored in the Command property

    Dim originalCommand As String = connection.Command

    ' Execute the stored procedure

    connection.Command = "EXECUTE [General_Purpose].[dbo].[usp_tblSubjectDelete] '" & subjectStringID & "'"

    connection.Execute()

    ' Restore the statement of the Command property to its original value

    connection.Command = originalCommand

    End Sub

     

    If I copy the value of connection.Command just before connection.Execute() and I run this command in my sql server management studio all works perfect.. But in code it just doens't delete anything.. It's not throwing any error and the statement that has to be executed just works.

    Any explanation for this?

     

    Thx in advance,

    Neil.

Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.