doeks_ieya
New Member
I have a stored procedure like below:\[code\]create proc wsp_test( @age int , @userName varchar(30))as select userID, userName from Users where userName like '%' + @userName + '%' and age > @age\[/code\]And here is C# code:\[code\]case 1)SqlCommand _cmd = new SqlCommand();_cmd.Parameters.Add("age", SqlDbType.Int, 4);_cmd.Parameters.Add("UserName", SqlDbType.VarChar, 30);case 2)SqlCommand _cmd = new SqlCommand();_cmd.Parameters.Add("age", SqlDbType.Int);_cmd.Parameters.Add("UserName", SqlDbType.VarChar);case 3)SqlCommand _cmd = new SqlCommand();_cmd.Parameters.Add("age");_cmd.Parameters.Add("UserName");case 4)SqlCommand _cmd = new SqlCommand();_cmd.CommandText = "EXEC wsp_test 20, 'John'";\[/code\]Now my question is that what has it got to do with performance to specify the parameter's datatype or length?Which one has the best performance? Are there any documents from Microsoft's web site that I can rely on?Or are there any security reasons to specify the parameter's datatype and length?