473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How 2 store values through Stored Procedure from ARRAYLISTwhich is from Database only

KalariaNitya
hi All,

i am working on ASP.NET and Sql Server 2005.

i want to send arraylist from frontend to sql server and fatch it's value in database and then insert one by one row..

means in my arraylist more than one rows are present. and i want to send that arraylist in database and then fatch value from that arraylist and then store.

i want to use database connection only one time to send arraylist.

can any body help me, how to do that?

any help will be really appriciated..
Jul 18 '08 #1
5 955
r035198x
13,262 8TB
I'm still not clear on one thing. Do you want to store the ArrayList it self in the database or just the ArrayList's contents?
Jul 18 '08 #2
first of all Thanks r035198x ,

i have to store arraylist contant in database

i have one arraylist which has values with comma(,) seperated...

it contains more then one row.

i send it already in database

now i want to fatch values which is comma(,) seperated & stored in table...

now u get what i want?
Jul 18 '08 #3
r035198x
13,262 8TB
Maybe post some relevant code and explain the part that you are stuck with now.
Jul 18 '08 #4
hi,
i made stored procedure for that..


Expand|Select|Wrap|Line Numbers
  1.  Alter procedure b
  2. (    
  3.     @code varchar(Max),
  4.     @policyid varchar(Max),
  5.     @sign varchar(Max),
  6.     @discount varchar(Max),
  7.     @commission varchar(Max)
  8. )
  9. As
  10. Begin
  11.     --for code
  12.     declare @varcode varchar(MAX)
  13.     declare @splitcode varchar(MAX)
  14.  
  15.     --for policyid
  16.     declare @varpolicyid varchar(MAX)
  17.     declare @splitpolicyid varchar(MAX)
  18.  
  19.     --for discountedsign 
  20.     declare @varsign varchar(MAX)
  21.     declare @splitsign varchar(MAX)
  22.  
  23.     --for discountgiventoclients
  24.     declare @vardiscount varchar(MAX)
  25.     declare @splitdiscount varchar(MAX)
  26.  
  27.     --for commissiongivenbycompany
  28.     declare @varcommission varchar(MAX)
  29.     declare @splitcommission varchar(MAX)
  30.  
  31.     set @varcode= @code
  32.     set @varpolicyid=@policyid
  33.     set @varsign=@sign
  34.     set @vardiscount=@discount
  35.     set @varcommission=@commission
  36.  
  37.     print len(@varcode)
  38.     print len(@varpolicyid)
  39.     print len(@varsign)
  40.     print len(@vardiscount)
  41.     print len(@varcommission)
  42.  
  43.     while (len(@varcode) > 0 ) and (len(@varpolicyid) > 0 ) and (len(@varsign) > 0 ) and (len(@vardiscount) > 0)    and (len(@varcommission) > 0 ) 
  44.         begin
  45.             set @splitcode         =  substring(@varcode,0,charindex(',',@varcode))
  46.             set @splitpolicyid   =  substring(@varpolicyid,0,charindex(',',@varpolicyid))
  47.             set @splitsign       =  substring(@varsign,0,charindex(',',@varsign))
  48.             set @splitdiscount   =  substring(@vardiscount,0,charindex(',',@vardiscount))
  49.             set @splitcommission =  substring(@varcommission,0,charindex(',',@varcommission))
  50.  
  51.                 print @splitcode
  52.                 print @splitpolicyid
  53.                 print @splitsign
  54.                 print @splitdiscount
  55.                 print @splitcommission
  56.  
  57.             set @varcode = substring(@varcode,charindex(',',@varcode)+1,len(@varcode))
  58.             set @varpolicyid = substring(@varpolicyid,charindex(',',@varpolicyid)+1,len(@varpolicyid))
  59.             set @varsign = substring(@varsign,charindex(',',@varsign)+1,len(@varsign))
  60.             set @vardiscount = substring(@vardiscount,charindex(',',@vardiscount)+1,len(@vardiscount))
  61.             set @varcommission = substring(@varcommission,charindex(',',@varcommission)+1,len(@varcommission))
  62.  
  63.                 print len(@varcode)
  64.     print len(@varpolicyid)
  65.     print len(@varsign)
  66.     print len(@vardiscount)
  67.     print len(@varcommission)
  68.  
  69.             insert into commission_master
  70.             (
  71.                 code,
  72.                 policyid,
  73.                 discountedsign,
  74.                 discountgiventoclients,
  75.                 commissiongivenbycompany
  76.             )
  77.             values
  78.             (
  79.                 @splitcode,
  80.                 @splitpolicyid,
  81.                 @splitsign,
  82.                 @splitdiscount,
  83.                 @splitcommission
  84.             )            
  85.         end
  86. End



exec b 'A0000001,BR000036,SA000038','p0000001,p0000008,p0 000009','<=,<=,>','10,20,30','40,50,60'


up to two rows it instered successfully

but when the time of instering third row
it gives error

Msg 8114, Level 16, State 5, Procedure b, Line 69
Error converting data type varchar to numeric.

out put up to two rows like below:

1 A0000001 p0000001 <= 10 40
2 BR000036 p0000008 <= 20 50

please help me...

thanking u in advanced...
Jul 18 '08 #5
r035198x
13,262 8TB
..

Msg 8114, Level 16, State 5, Procedure b, Line 69
Error converting data type varchar to numeric.

...
The error message does seem to be explaining what the problem is ...
Jul 21 '08 #6

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

Similar topics

4
by: Christopher Brandsdal | last post by:
Hi! I have a delicatg problem.... I have made a registration form for adding my friends information in a database. The problem is that I want to connect the persons with companies in the same...
2
by: serge | last post by:
My project is to automate testing of Stored Procedures of type SELECT (at least for now). I want to create a table where each stored procedure's input parameter values are entered and in another...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
1
by: esmith2112 | last post by:
We all of a sudden find ourselves in dire straits, because we have one of those mysteries where everything used to work, and apparently, all of a sudden everything went to pot just in time for a...
7
by: Peter D.C. | last post by:
Hi I want to update data hold in several textbox controls on an asp.net form. But it seems like it is the old textbox values that is "re-updates" through a stored procedure who updates a SQL...
5
by: Alan T | last post by:
Currently our SQL Server 2000 database table field is using char to store as boolean, ie. "T" or "F". Now we change the field from char to bit field. I am not sure how it has impact on the C#...
11
by: c676228 | last post by:
Hi everyone, I am just wodering in asp program, if there is anybody writing store procedure for inserting data into database since there are so many parameters need to be passed into store...
4
by: scparker | last post by:
Hello, We have a stored procedure that does a basic insert of values. I am then able to retrieve the ID number created for this new record. We are currently using ASP.NET 2.0 and use N-Tier...
1
KalariaNitya
by: KalariaNitya | last post by:
hi All, i am working on ASP.NET and Sql Server 2005. i want to send arraylist from frontend to sql server and fatch it's value in database and then insert one by one row.. means in my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.