Hi,
I'm having a asp.net listbox on the front end webform with multiple selection, after user selecting multiple items, i'm capturing the DataKeyValue of listbox(which is amenity_id of bigint) and looping all the selected items to a string with comma sepearated values.
For example if user selects first 4 options, my output string will be like this (1,2,3,4) and i'm passing this as a string type to my data access layer and then to my below stored proc.
I'm geting this error while inserting.. i know that my data type is of bigint and i'm trying to insert string type..
can anyone please help me out.. i need to convert the string type to INT type and insert data. below are my stored procs:
ALTER PROCEDURE [usp_add_amenities]
(-- Add the parameters for the stored procedure here
@amenities_id_list varchar(4000),
@id varchar(50))
AS
BEGIN
SET NOCOUNT ON;
DECLARE @pos int, @curruntLocation char(20)
SELECT @pos=0
--SELECT @input = '1234,2345,3456'
SELECT @amenities_id_list = @amenities_id_list + ','
WHILE CHARINDEX(',',@amenities_id_list) > 0
BEGIN
SELECT @pos=CHARINDEX(',',@amenities_id_list)
SELECT @curruntLocation = RTRIM(SUBSTRING(@amenities_id_list,1,@pos-1))
INSERT INTO ref_amenities (amenity_id, id) VALUES (@curruntLocation, @id)
END
END
This is where i'm splitting the comma seperated values and inserting them into table
can anyone please help me..
awaiting your response,
Many Thanks