0

Can any body explain me Adding parameters to AddParams method I cant understand the code

in this code it try to delete a row from article table, for that i use SqlDataAdapter,DataSet and DataTable ,
//Preparing Delete Sql Command

dataAdapter.DeleteCommand=conn.CreateCommand();
dataAdapter.DeleteCommand.CommandText="DELETE FROM article WHERE artId=@artId";
AddParams(dataAdapter.DeleteCommand,"artId");

This is the place i cant not understand
Adding Parameters to the AddParams method

private void AddParams(SqlCommand cmd,params string[] cols)
{
//Adding Hectice parameters in SQL Commands
foreach(string col in cols)
{
cmd.Parameters.Add("@"+col,SqlDbType.Char,0,col);
}

}
2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by MrBlack
0
dataAdapter.DeleteCommand=conn.CreateCommand();
dataAdapter.DeleteCommand.CommandText="DELETE FROM article WHERE artId=@artId";
dataAdapter.DeleteCommand.Parameters.Add("@artId",SqlDbType.Char,10);
0

What is SqlDbType.Char , 10 , why does it use for, i m new to programming, i dont understand this

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.