public static Dictionary <string, object> IntoTable(string connectionString, List <string> fieldNames, List <List <string> > values, string tableName, string dbSchema = "dbo") { DynaFunctions f = new DynaFunctions(); string result = ""; string names = ""; List <string> data = new List <string>(); foreach (string fN in fieldNames) { names += fN + ","; } names = names.Substring(0, names.Length - 1); data.Add(names); foreach (List <string> j in values) { string s = ""; foreach (string k in j) { s += "'" + k.ToString() + "',"; } s = s.Substring(0, s.Length - 1); data.Add(s); string commandString = "INSERT INTO [" + dbSchema + "]." + tableName + " (" + names + ") VALUES (" + s + ");"; result = f.executeSqlCommand(commandString, connectionString); } return(new Dictionary <string, object> { { "message", result }, { "data", data }, }); }
public static Dictionary <string, object> Database(String connectionString, string dbName) { DynaFunctions f = new DynaFunctions(); string commandString = "USE [master]; DROP DATABASE " + dbName; string result = f.executeSqlCommand(commandString, connectionString); return(new Dictionary <string, object> { { "message", result }, { "dbName", dbName }, }); }
public static Dictionary <string, object> Table(string connectionString, string tableName, string dbSchema = "dbo") { DynaFunctions f = new DynaFunctions(); string commandString = "DROP TABLE [" + dbSchema + "]." + tableName; string result = f.executeSqlCommand(commandString, connectionString); return(new Dictionary <string, object> { { "message", result }, { "tablename", tableName }, }); }
public static Dictionary <string, object> ColumnsFromTable(string connectionString, List <string> fieldNames, string tableName, string dbSchema = "dbo") { DynaFunctions f = new DynaFunctions(); string result = ""; foreach (string fn in fieldNames) { string commandString = "ALTER TABLE [" + dbSchema + "]." + tableName + " DROP COLUMN " + fn + ";"; result = f.executeSqlCommand(commandString, connectionString); } return(new Dictionary <string, object> { { "message", result }, }); }
public static Dictionary <string, object> Table(List <String> fieldNames, List <string> fieldTypes, string connectionString, string tableName, string dbSchema = "dbo") { DynaFunctions f = new DynaFunctions(); int k = 0; string tableFields = "("; foreach (string fn in fieldNames) { tableFields += fn + " " + fieldTypes[k] + ","; } tableFields += ");"; string commandString = "CREATE TABLE [" + dbSchema + "]." + tableName + tableFields; string result = f.executeSqlCommand(commandString, connectionString); return(new Dictionary <string, object> { { "message", result }, { "tablename", tableName }, }); }