Click here to Skip to main content
15,891,765 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here these my query for deleting
SQL
ALTER PROCEDURE [dbo].[sp_DeleteContactSubscriptionDetail]

	@contactid as varchar(3)
AS
BEGIN
set @contactid=convert (int,@contactid)
	Delete from Contactsubscriptiondetail where contactid=@contactid
	
END


and these is my code
C#
object[,] objdel = new object[1, 2]
        {
            {"@contactid",Convert.ToInt32(Txtcontactid.Text)}};
        DBTask.ExecuteQuery_SP("sp_DeleteContactSubscriptionDetail", objdel);

and while debugging i am getting error Conversion failed when converting the varchar value '*' to data type int. and it is not deleting
Posted
v2

1 solution

The problem is you have declared the parameter as varchar in procedure, but passing it as a integer value.
C#
{"@contactid",Convert.ToInt32(Txtcontactid.Text)}};
        DBTask.ExecuteQuery_SP("sp_DeleteContactSubscriptionDetail", objdel);

If you are converting here, then declare the parameter as integer in procedure.

You are unnecessarily converting again in procedure using...
SQL
set @contactid=convert (int, @contactid)


So, declare as integer and try.
SQL
@contactid as int
 
Share this answer
 
Comments
ManojMurali 23-Apr-13 3:11am    
Thanks Dear for your quick answer and its working now.
Most welcome buddy... My pleasure...
Thanks for accepting and up-voting. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900