Showing posts with label backend. Show all posts
Showing posts with label backend. Show all posts

Saturday, February 25, 2012

.net 1.1 SqlDbType accepts varchar(MAX)

My app uses .net 1.1 and MS SQL 2005 as backend. How to add a SqlParamter that is varchar(MAX)?


SqlParameter myParameter = new SqlParameter("@.Description",SqlDbType.VarChar,whatToPutHere?,ParameterDirection.Input,
true,0,0,"Whatever",DataRowVersion.Current,"Whatever");


That's the size position, right? Put the max value you expect to have. Max allowable is 8000

|||

Try:

SqlParameter myParameter = new SqlParameter("@.Description",SqlDbType.VarChar);

|||

Motley:

SqlDbType.VarChar

I'm not positive about this, but make sure that if you leave the VarChar declaration w/o a length parm that it won't default to VarChar(1) (ie, max 1 char). I think it may do this but I could be wrong. I am pretty sure that if you declare a variable as

declare @.v varchar

that it sets the max size to 1, for example (but I'mnot anywhere where I can double check that statment, though<g>)

|||

Motley:

SqlDbType.VarChar

I'm not positive about this, but make sure that if you leave the VarChar declaration w/o a length parm that it won't default to VarChar(1) (ie, max 1 char). I think it may do this but I could be wrong. I am pretty sure that if you declare a variable as

declare @.v varchar

that it sets the max size to 1, for example (but I'mnot anywhere where I can double check that statment, though<g>)