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);
}

}

Recommended Answers

All 3 Replies

dataAdapter.DeleteCommand=conn.CreateCommand();
dataAdapter.DeleteCommand.CommandText="DELETE FROM article WHERE artId=@artId";
dataAdapter.DeleteCommand.Parameters.Add("@artId",SqlDbType.Char,10);

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

Helloooooooo,plz help me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.