From db5e0f6c3089697425ae877ee0672f0ea384dbc8 Mon Sep 17 00:00:00 2001 From: Valeriano Alfonso Rodriguez Date: Thu, 16 Dec 2021 16:20:07 +0100 Subject: [PATCH] TableBL and ProcedureBL: Fix escaping of names. --- VAR.DatabaseExplorer/Code/BusinessLogic/ProcedureBL.cs | 2 +- VAR.DatabaseExplorer/Code/BusinessLogic/TableBL.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/VAR.DatabaseExplorer/Code/BusinessLogic/ProcedureBL.cs b/VAR.DatabaseExplorer/Code/BusinessLogic/ProcedureBL.cs index 5b738cb..2b84dce 100644 --- a/VAR.DatabaseExplorer/Code/BusinessLogic/ProcedureBL.cs +++ b/VAR.DatabaseExplorer/Code/BusinessLogic/ProcedureBL.cs @@ -91,7 +91,7 @@ namespace VAR.DatabaseExplorer.Code.BusinessLogic public static void Procedure_GenerateCreate(Procedure routine, StreamWriter txtWriter) { - string routineName = string.Format("{0}.{1}", routine.Schema, routine.Name); + string routineName = string.Format("[{0}].[{1}]", routine.Schema, routine.Name); if (routine.Type.ToUpper() == "PROCEDURE") { txtWriter.WriteLine(string.Format("PRINT '*** Creating procedure {0}....';", routineName)); diff --git a/VAR.DatabaseExplorer/Code/BusinessLogic/TableBL.cs b/VAR.DatabaseExplorer/Code/BusinessLogic/TableBL.cs index 535d143..3f88f0e 100644 --- a/VAR.DatabaseExplorer/Code/BusinessLogic/TableBL.cs +++ b/VAR.DatabaseExplorer/Code/BusinessLogic/TableBL.cs @@ -46,7 +46,7 @@ namespace VAR.DatabaseExplorer.Code.BusinessLogic { if (t.Type != "BASE TABLE") { return; } - string tableName = string.Format("{0}.{1}", t.Schema, t.Name); + string tableName = string.Format("[{0}].[{1}]", t.Schema, t.Name); txtWriter.WriteLine(string.Format("PRINT '*** Importing data of {0}....';", tableName)); IEnumerable rows = TableDA.GetData(conectionString, tableName); if (t.Columns.Any(c => c.Indentity)) @@ -89,7 +89,7 @@ namespace VAR.DatabaseExplorer.Code.BusinessLogic { if (table.Type != "BASE TABLE") { return; } - string tableName = string.Format("{0}.{1}", table.Schema, table.Name); + string tableName = string.Format("[{0}].[{1}]", table.Schema, table.Name); txtWriter.WriteLine(string.Format("PRINT '*** Creating tabla {0}....';", tableName)); txtWriter.WriteLine(string.Format("IF EXISTS (SELECT TOP 1 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{0}' AND TABLE_NAME = '{1}')", table.Schema, table.Name)); txtWriter.WriteLine("BEGIN"); @@ -169,7 +169,7 @@ namespace VAR.DatabaseExplorer.Code.BusinessLogic { if (table.Type != "VIEW") { return; } - string viewName = string.Format("{0}.{1}", table.Schema, table.Name); + string viewName = string.Format("[{0}].[{1}]", table.Schema, table.Name); txtWriter.WriteLine(string.Format("PRINT '*** Creating view {0}....';", viewName)); txtWriter.WriteLine(string.Format("IF EXISTS (SELECT TOP 1 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{0}' AND TABLE_NAME = '{1}')", table.Schema, table.Name)); txtWriter.WriteLine("BEGIN");