Exemplo n.º 1
0
        public void CreateTable(string tableName)
        {
            string tsqlStr = @"if OBJECT_ID ('{0}', 'U') is null
                                begin
	                                create table [{0}] (id int identity primary key, FileName nvarchar(max), FileContent nvarchar(max))
                                end";
            //string strSql = string.Format("create table [{0}] (id int identity primary key, FileName nvarchar(max), FileContent nvarchar(max))", tableName);
            string strSql = string.Format(tsqlStr, tableName);

            Util.Logger.LogMessage(string.Format("creating table [{0}]", tableName));
            m_Csql.ExecuteSqlScript(strSql);
        }
Exemplo n.º 2
0
        public void CreateTable(string tableName)
        {
            string strSql = string.Format("create table [{0}] (id int identity primary key, FileName nvarchar(max), FileContent nvarchar(max))", tableName);

            m_Csql.ExecuteSqlScript(strSql);
        }
Exemplo n.º 3
0
        private void RunScript(string scriptname)
        {
            //if nothing to run, return
            if (string.IsNullOrEmpty(scriptname))
            {
                return;
            }

            Cursor saveCur = this.Cursor;
            string FullScriptName;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                Application.DoEvents();
                MainForm.LogMessage(string.Format("Executing {0}...", scriptname));
                // Server srv = new Server(Globals.Server);


                //Database db = srv.Databases[Globals.Database];
                MainForm.LogMessage("db name = " + Globals.credentialMgr.Database);

                if (-1 == scriptname.IndexOf('\\'))
                {
                    FullScriptName = Application.StartupPath + "\\" + scriptname;
                    if (!File.Exists(FullScriptName))
                    {
                        FullScriptName = Application.StartupPath + @"\Reports\" + scriptname;
                        if (!File.Exists(FullScriptName))
                        {
                            FullScriptName = Globals.AppDataPath + "\\" + scriptname;
                            if (!File.Exists(FullScriptName))
                            {
                                FullScriptName = Globals.AppDataPath + "\\reports\\" + scriptname;
                            }
                        }
                    }
                }
                else
                {
                    FullScriptName = scriptname;
                }

                if (!File.Exists(FullScriptName))
                {
                    MainForm.LogMessage("Script " + FullScriptName + "doesn't exist", MessageOptions.All);
                    return;
                }

                //db.ExecuteNonQuery(File.ReadAllText(FullScriptName), Microsoft.SqlServer.Management.Common.ExecutionTypes.ContinueOnError);
                CSql mysql = new CSql(Globals.credentialMgr.ConnectionString);
                //MainForm.LogMessage("Connection string inside execute script " + Globals.credentialMgr.ConnectionString);
                mysql.ExecuteSqlScript(File.ReadAllText(FullScriptName));
                MainForm.LogMessage("full script " + FullScriptName);
                MainForm.LogMessage(string.Format("Execution of {0} complete.", FullScriptName));
            }
            finally
            {
                this.Cursor = saveCur;
            }
        }