Hoz:
If you don't specify the length, .net will go to some length to figure it
out. It does so based on the type...if it's a varchar/char/nchar/nvarchar/
it gets the length of the string and uses that.
In other words, specifying a length will be faster..but I wouldn't say much
faster...the code .net goes through to figure out the length isn't all that
trivial though, so it's a hard question to answer.
If you are really curious, get Lutz Reflector and open up the SqlParameter's
ActualSize property, you'll see what it's doing when you don't specify the
length..
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"hoz" <as*@me.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi ,
i have a complex ideas about sqlparameter lenght . lets say i have the
following code
mycom.Parameters.Add("@sip",SqlDbType.NVarChar);
mycom.Parameters["@sip"].Value = siparisid ;
in the stored procedure : create proc SP @kid int , @sip nvarchar(50)
as ...
as you have seen , i dont specify parameter lenght in C# . Why ? because
when some changes occurs in db , i only make change in stored procedure.
Does it decrease performance ? and which one is better to use : 1- using
parameter lenght in c# , 2 - using parameter lenght in sp , 3- both of
them . And why ?
thanks for your help