Is something like this possible:
int MyParameter = 3356;
DataTable x = new DataTable("CommandParams");
x.Columns.Add("ParamName");
x.Columns.Add("ParamType");
x.Columns.Add("Object");
DataRow y = x.NewRow();
y["ParamName"] = "@SomeParamName";
y["ParamType"] = MyParameter.GetType();
y["Object"] = MyParameter;
SqlCommand z = new SqlCommand();
z.Parameters.Add(new SqlParameter(x.Rows[0]["ParamName"], (x.Rows[0]["ParamType"])x.Rows[0]["Object"]);
I'm trying to come up with a method that can loop through a datatable (or something) and add parameters to an SqlCommand instead of typing out hundreds of lines of code if there are hundreds of parameters.
Thoughts?