summaryrefslogtreecommitdiff
path: root/Aktywator/Sql.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Aktywator/Sql.cs')
-rw-r--r--Aktywator/Sql.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/Aktywator/Sql.cs b/Aktywator/Sql.cs
index cf0eb38..b3f2104 100644
--- a/Aktywator/Sql.cs
+++ b/Aktywator/Sql.cs
@@ -83,5 +83,31 @@ namespace Aktywator
}
return true;
}
+
+ internal void insert(string table, Dictionary<string, object> columns)
+ {
+ StringBuilder query = new StringBuilder();
+ query.Append("INSERT INTO ");
+ query.Append(table);
+ query.Append(" (");
+ List<string> keys = new List<string>();
+ List<string> parameters = new List<string>();
+ foreach (string key in columns.Keys)
+ {
+ keys.Add("`" + key + "`");
+ parameters.Add("@" + key);
+ }
+ string[] fields = keys.ToArray();
+ query.Append(String.Join(", ", fields));
+ query.Append(") VALUES(");
+ query.Append(String.Join(", ", parameters.ToArray()));
+ query.Append(")");
+ OleDbCommand command = new OleDbCommand(query.ToString(), connection);
+ foreach (KeyValuePair<string, object> column in columns)
+ {
+ command.Parameters.AddWithValue("@" + column.Key, column.Value);
+ }
+ command.ExecuteScalar();
+ }
}
}