SQL Parameter Question

  • Thread starter Thread starter Prashanth
  • Start date Start date
P

Prashanth

Hi ,

I want to make a stored proc call thru .NET . I use the SqlParameter objects
to create input parameters and set it's value.
SqlParameter myParameter = new
SqlParameter("@Description",SqlDbType.VarChar);
myParameter.Value = "some string size not known. but max size of the string
can be only 1024 characters";

Note : I have not mentioned the size of the parameter using
myParameter.Size = 1024;


My Question is what happens if i donot want to specify the Size for the
SqlParameter? Will it work properly. what is the default size .NET sets for
the SqlDbType.VarChar .



Thanx,

PK
 
I'm not sure I understand your question...
However, why don't you pass the actual length of the string in the third
parameter of the CTOR:
SqlParameter("@Description",SqlDbType.VarChar,myString.length);

For an input parameter, at execution time you will always know the length of
the string at the time you execute the line above

José
 
Back
Top