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. General Programming
  3. C#
  4. Stored Procedure in a RichTextBox

Stored Procedure in a RichTextBox

Scheduled Pinned Locked Moved C#
database
4 Posts 2 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.
  • S Offline
    S Offline
    shehezada
    wrote on last edited by
    #1

    Hi there, I have a stored procedure written on a RichTextBox. On the click of a button, this stored procedure should be executed and errors, if any, should be displayed in a messagebox. Thanks in advance!

    M 1 Reply Last reply
    0
    • S shehezada

      Hi there, I have a stored procedure written on a RichTextBox. On the click of a button, this stored procedure should be executed and errors, if any, should be displayed in a messagebox. Thanks in advance!

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      Hi! You can access the text in the RTB via its Text property (I can't see what else this has to do with the topic). To execute a SP with a given name you can use classes from the System.Data.* namespace, depending on the RDBMS you want to use, for example the SqlCommand class. There's a ton of samples for this on MSDN for example, try googling for it if you still have troubles.

      Regards, mav -- Black holes are the places where God divided by 0...

      S 1 Reply Last reply
      0
      • M mav northwind

        Hi! You can access the text in the RTB via its Text property (I can't see what else this has to do with the topic). To execute a SP with a given name you can use classes from the System.Data.* namespace, depending on the RDBMS you want to use, for example the SqlCommand class. There's a ton of samples for this on MSDN for example, try googling for it if you still have troubles.

        Regards, mav -- Black holes are the places where God divided by 0...

        S Offline
        S Offline
        shehezada
        wrote on last edited by
        #3

        Thanks mav, Currently I am using this option. The problem is that SqlCommand class can handle only one SQL command at time. What I need is to send an entire SP, execute it and after the whole SP is executed in "one go"; 1. If successful, a message box saying "Successful Execution" should be displayed; else, 2. Whatever exception has been returned, that needs to be displayed.

        M 1 Reply Last reply
        0
        • S shehezada

          Thanks mav, Currently I am using this option. The problem is that SqlCommand class can handle only one SQL command at time. What I need is to send an entire SP, execute it and after the whole SP is executed in "one go"; 1. If successful, a message box saying "Successful Execution" should be displayed; else, 2. Whatever exception has been returned, that needs to be displayed.

          M Offline
          M Offline
          mav northwind
          wrote on last edited by
          #4

          You can't "send an entire SP". A SP is something stored within the DB (hence the name). You _could_ execute an SQL command containing something like "CREATE PROCEDURE ..." to create a SP on-the-fly, but I think that's not a good solution. If you have several queries you have to execute together, then the SP should be available in the DB, not be created everytime, IMO.

          Regards, mav -- Black holes are the places where God divided by 0...

          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