Manages Sql Connection String
Inheritance: ICloneable
示例#1
0
        public object Clone()
        {
            SqlConnectionString scs = new SqlConnectionString();

            scs.auth     = auth;
            scs.database = database;
            scs.password = password;
            scs.server   = server;
            scs.user     = user;
            return(scs);
        }
示例#2
0
        private SqlConnectionString GetConnectionString(IEnumerable <XElement> props)
        {
            SqlConnectionString connStr = new SqlConnectionString();

            IEnumerator <XElement> enumerator = props.GetEnumerator();

            while (enumerator.MoveNext())
            {
                XElement ele = enumerator.Current;
                if (ele.Name.LocalName == "Server")
                {
                    connStr.Server = ele.Value;
                }
                if (ele.Name.LocalName == "Catalog")
                {
                    connStr.Database = ele.Value;
                }
            }
            return(connStr);
        }
示例#3
0
        public DatabaseCreateResult RunScript(
            SqlConnectionString conString, string file, string variables)
        {
            using (var proc = new Process())
            {
                proc.StartInfo.FileName = SqlCmd;
                if (conString.Authentication == false)
                {
                    proc.StartInfo.Arguments = String.Format(@"-U{0} -P{1}", conString.UserID, conString.Password);
                }
                else
                {
                    proc.StartInfo.Arguments += String.Format(" -b -E ");
                }
                proc.StartInfo.Arguments += variables;

                proc.StartInfo.Arguments             += String.Format(@"-S{0} -i""{1}""", conString.Server, file);
                proc.StartInfo.UseShellExecute        = false;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.RedirectStandardError  = true;
                proc.StartInfo.CreateNoWindow         = true;

                LogMessage(
                    MessageImportance.Normal,
                    string.Format("Executing SQLCmd: {0}", proc.StartInfo.Arguments));

                proc.Start();

                var result = new StringBuilder(proc.StandardOutput.ReadToEnd());
                proc.WaitForExit();
                result.Append(proc.StandardOutput.ReadToEnd());

                LogMessage(
                    MessageImportance.Normal,
                    string.Format("Execution Results: {0}", result.ToString()));

                return(new DatabaseCreateResult {
                    Output = result.ToString(), IsSuccessful = proc.ExitCode != 1
                });
            }
        }
        public DatabaseCreateResult RunScript(
            SqlConnectionString conString, string file, string variables)
        {
            using (var proc = new Process())
            {
                proc.StartInfo.FileName = SqlCmd;
                if (conString.Authentication == false)
                {
                    proc.StartInfo.Arguments = String.Format(@"-U{0} -P{1}", conString.UserID, conString.Password);
                }
                else
                {
                    proc.StartInfo.Arguments += String.Format(" -b -E ");
                }
                proc.StartInfo.Arguments += variables;

                proc.StartInfo.Arguments += String.Format(@"-S{0} -i""{1}""", conString.Server, file);
                proc.StartInfo.UseShellExecute = false;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.RedirectStandardError = true;
                proc.StartInfo.CreateNoWindow = true;

                LogMessage(
                    MessageImportance.Normal,
                    string.Format("Executing SQLCmd: {0}", proc.StartInfo.Arguments));

                proc.Start();

                var result = new StringBuilder(proc.StandardOutput.ReadToEnd());
                proc.WaitForExit();
                result.Append(proc.StandardOutput.ReadToEnd());

                LogMessage(
                    MessageImportance.Normal,
                    string.Format("Execution Results: {0}", result.ToString()));

                return new DatabaseCreateResult { Output = result.ToString(), IsSuccessful = proc.ExitCode != 1 };
            }
        }
        private SqlConnectionString GetConnectionString(IEnumerable<XElement> props)
        {
            SqlConnectionString connStr = new SqlConnectionString();

            IEnumerator<XElement> enumerator = props.GetEnumerator();

            while (enumerator.MoveNext())
            {
                XElement ele = enumerator.Current;
                if (ele.Name.LocalName == "Server")
                {
                    connStr.Server = ele.Value;
                }
                if (ele.Name.LocalName == "Catalog")
                {
                    connStr.Database = ele.Value;
                }
            }
            return connStr;
        }
 public object Clone()
 {
     SqlConnectionString scs = new SqlConnectionString();
     scs.auth = auth;
     scs.database = database;
     scs.password = password;
     scs.server = server;
     scs.user = user;
     return scs;
 }