public static int Dynamicarray(string connectionString, Dictionary<string,object> parameters)
{
using (SqlConnection con = Database.GetConnection())
{
string column_name;
string value;
foreach (KeyValuePair<string,object> kvp in parameters)
{
column_name =kvp.Key+",";
value = kvp.Value.ToString()+ ",";
}
column_name = column_name.Remove(column_name.LastIndexOf(","));
value = value.Remove(value .LastIndexOf(","));
SqlCommand cmdExecute = new SqlCommand("insert into tbl1 ("+column_name+") values("+ value+ ")",con);
return cmdExecute.ExecuteNonQuery();
}
}.
haven't tested, please fix if you find any typo's
hope this helps