views:

1416

answers:

3

Hi,

I normally set my column size when creating a parameter in ADO.NET

But what size do I use if the column is VARCHAR(MAX)?

cmd.Parameters.Add("@blah", SqlDbType.VarChar, ?????).Value = blah;

+4  A: 

In this case you use -1.

Michał Chaniewski
See also MSDN docs: http://msdn.microsoft.com/en-us/library/bb399384.aspx
Rowland Shaw
A: 

Can I omit it like this to get the same result?

cmd.Parameters.Add("@blah", SqlDbType.VarChar).Value = blah;

A: 

Yes you can omit the size.

kings