Friday, April 10, 2009

Value of output parameter truncates.Why?

why value of output parameter truncated in Here is the possibel reason.....
In database programming with SQL-Server and C# Some time we use output parameters to get value From database to C# variable.
There is one constructor of sql parameter which takes two arguments.
(1)parameter name.(2)Default value.

SqlParameter sp = new SqlParameter("@Name","");

When you provide default value and you are not providing Size of parameter Default size will be the length of default value.
In above case size of parameter will be 1. So sql will return only single character as output.
To avoid this problem you have to provide size of output parameter in C#.

sp.Size = 5;


No comments:

Post a Comment

Comments posted on ASP.Net Ajax Tutorials Blog are moderated and will be approved only if they are on-topic and not abusive. Please email me or my team for tech-support or blogging related questions. Avoid including website URLs in your comments - Thanks Author