DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

ADO.NET Command Object: Adding A New Parameter

  • submit to reddit
        There are many ways of adding a new parameter to an command object. One way is pass parameter and it's data type in one go.
System.Data.SqlClient.SqlParameter param;
param = command.Parameters.Add("@CategoryName", SqlDbType.VarChar, 15);
param.Direction= System.Data.ParameterDirection.Input;
param.Value = cat;