Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Evaluate returnvalues of stored procedures used in TableAdapterManager.UpdateAll

Evaluate returnvalues of stored procedures used in TableAdapterManager.UpdateAll

Scheduled Pinned Locked Moved Database
csharpquestionsql-servervisual-studio
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    atrus2711
    wrote on last edited by
    #1

    Hello forum, I'm using Visual Studio 2013 and MSSQL 2012. In my VB.net-application, I'm using a typed dataset to read data from MSSQL and write back additions, changes and deletions. I built Stored Procedures for the 4 commands (Select, Update, Delete and Insert), and assigned them to the 4 commands in the tableadapter. All works fine; all 4 command do their job in my app. BUT: under some (well defined) circumstances the SPs return a returnvalue of 1. This returnvalue signals overlapping of the pending data and the old data in the table. Thus, the SPs do enforce that the time intervals in the table do not overlap. It works, but it works silently: "illegal" inputs are rejected, but without notice. So, I'd like to get access to this returnvalue, in order to show a message like "Your pending data overlap existing intervals and can therefore not be saved". How can i access the returncode of SPs used in TableAdaptermanager?

    A 1 Reply Last reply
    0
    • A atrus2711

      Hello forum, I'm using Visual Studio 2013 and MSSQL 2012. In my VB.net-application, I'm using a typed dataset to read data from MSSQL and write back additions, changes and deletions. I built Stored Procedures for the 4 commands (Select, Update, Delete and Insert), and assigned them to the 4 commands in the tableadapter. All works fine; all 4 command do their job in my app. BUT: under some (well defined) circumstances the SPs return a returnvalue of 1. This returnvalue signals overlapping of the pending data and the old data in the table. Thus, the SPs do enforce that the time intervals in the table do not overlap. It works, but it works silently: "illegal" inputs are rejected, but without notice. So, I'd like to get access to this returnvalue, in order to show a message like "Your pending data overlap existing intervals and can therefore not be saved". How can i access the returncode of SPs used in TableAdaptermanager?

      A Offline
      A Offline
      atrus2711
      wrote on last edited by
      #2

      Behold, the power of a cup of coffee :rolleyes: Step 1: Raiserror in the SP with a severity of 11 or higher. 10 and lower ist considered a warning and won't throw an exception in vb.net.

      IF @intConflictingRows = 0
      BEGIN
      INSERT INTO [dbo].[tbl] (Fields) VALUES (@Values);

      SELECT Fields FROM tbl WHERE (ID = SCOPE\_IDENTITY())
      

      END
      ELSE
      BEGIN
      RAISERROR('Error: New interval overlapping existing data!', 11, 1)
      --do not return a return code here!
      END

      Step 2: Wrap the TableAdapterManager.UpdateAll in a Try-Catch-block, and catch all exception with a Messagebox.

      Try
      If Me.Validate() Then
      MyBindingsource.EndEdit()
      TableAdapterManager.UpdateAll(myDataset)
      Return True
      End If
      Return False
      Catch ex As Exception
      MessageBox.Show(ex.Message, "Error while saving!")
      Return False
      End Try

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups