473,471 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Converting a stringbuilder object to a stored procedure

Paul Johnson
97 New Member
Hi,

I have a bit of a problem with a stringbuilder and converting it so that I can use it as a stored proc

The original code goes like this

The initial part of the stringbuilder is simple enough - it is something like

Expand|Select|Wrap|Line Numbers
  1. Dim foo as New StringBuilder() = String.Empty
  2. foo = string.format("DELETE dog FROM animal WHERE name='{0}'", winform.AnimalName.ToString())
  3.  
the next part then checks if it's a multiple selection. If it's not, ";" is appended to it.
If there is more than one selection, " OR name='{0}'" is added onto the end to build up the SQL command which is then executed. There is no limit to the number of " OR name='{0}'" that can be added

The problem is that I'd like to change this into a stored procedure. A single instance is easy enough, it's the second one which is messing me about.

Is there a simple way to convert this form of concatenation and converting it to a stored procedure?

Thanks
Jan 11 '11 #1
1 2908
ck9663
2,878 Recognized Expert Specialist
Yes, there is a way. You still have to build a string to consolidate all those values that needs to be deleted. Pass it to an SP with a single variable. Inside the SP, use the IN function instead of OR operator.

The catch: the variable might not be big enough to accommodate the entire value.

Good Luck!!!

~~ CK
Jan 11 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: stjulian | last post by:
I have a stored procedure that is supposed to 1. Increment a counter in Table A via a transaction 2. Use this value as the primary key to add in an address to customers Table B (Referenced as a...
4
by: marc | last post by:
I've been developing a stored procedure that uses a user defined function in the query portion of the procedure. However, since the end product needs to allow for dynamic table names, the UDF will...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
1
by: Bill Struve | last post by:
You may want to do this, since the first single quote is missing in your e-mail: string sqlCounty = "'"; For (int i=0, i<cblCounties.Items.Count) { sqlCounty +=...
10
by: Rich | last post by:
I have a stored procedure on Sql Server2k. I can fill a data table which I can append to a dataset using an ADODB recordset object which gets populated from a command object that runs the sp. I...
2
by: singlal | last post by:
Hi, my question was not getting any attention because it moved to 2nd page; so posting it again. Sorry for any inconvenience but I need to get it resolved fast. Need your help! ...
1
by: karups | last post by:
Hi, I've got listbox in my .aspx page where the users can make multiple selection. So, Users can select 7 items in listbox, I have to take value from items and pass it to stored procedure to...
9
by: Frawls | last post by:
Hi I Am am having problems with a stored Procedure that i wrote. Basically whats happening is that the Stored procedure Runs fine when i EXECUTE it in SQL Query analyzer. But when i debug...
1
by: PVBHANU | last post by:
Hi, I am using DB2 V9.1 windows , can any one please tell me how to complile and execute a stored procedure. I followed Alldatabse->database->Application Object->stored procedure...But No...
1
by: jack1257 | last post by:
In this procedure im comparing two dates. Its the stored procedure could be executed. Im face an problem when executing this stored procedure. Error:exec sp_valid @coupon_no = 101 Msg 242,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.