Stored Procedure in a RichTextBox
-
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!
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 theSqlCommand
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...
-
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 theSqlCommand
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...
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.
-
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.
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...