示例#1
0
        /// <summary>
        /// For getting xml from database
        /// </summary>
        /// <param name="dom"></param>
        /// <returns></returns>
        public static string GetXml(XDocument dom, string ConnectionStr)
        {
            try
            {
                Database               db = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConnectionStr);
                DbParameter            parameter;
                DbCommand              cmd;
                IEnumerable <XElement> elems;
                IEnumerable <XElement> elem_list;
                string Procname = GetProcName(dom);
                cmd = db.GetStoredProcCommand(Procname);
                SetCommandTimeOut(cmd);
                string OutParameterName = "";

                elems     = dom.Descendants();
                elem_list = from elem in elems
                            select elem;
                foreach (XElement element in elem_list)
                {
                    parameter = cmd.CreateParameter();
                    if (element.Name.ToString() != "BIC" && element.Name.ToString() != "XsdName" && element.Name.ToString() != "procName" && element.Name.ToString() != "pFILESDATA")
                    {
                        OutParameterName        = element.Name.ToString();
                        parameter.ParameterName = "@" + element.Name.ToString();
                        if (element.Name.ToString().Trim() == "pERRORXML")
                        {
                            parameter.DbType    = DbType.Xml;
                            parameter.Direction = ParameterDirection.Output;
                        }
                        else
                        {
                            parameter.Value     = element.Value;
                            parameter.Direction = ParameterDirection.Input;
                        }

                        cmd.Parameters.Add(parameter);
                    }
                }

                db.ExecuteNonQuery(cmd);
                var retval = db.GetParameterValue(cmd, "@pERRORXML");
                return(Convert.ToString(retval));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        /// <summary>
        /// Reads the application connection   string from Config database
        /// </summary>
        /// <param name="connectionStringID">value of connectionStringID</param>
        /// <returns>application connection   string</returns>
        private static string GetApplicationConnectionStringFromDB(string connectionStringID)
        {
            string configDatabaseConnectionString = null;
            string applicationConnectionString    = null;

            configDatabaseConnectionString = GetDatabaseConnectionStringFromRegistry(CONFIGSDATABASEKEY);

            Database database = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(configDatabaseConnectionString);

            using (DbCommand cmd = database.GetStoredProcCommand(CONFIGURATIONCONNECTIONSTRINGGET))
            {
                database.AddInParameter(cmd, "@connectionStringKey", DbType.AnsiString, connectionStringID);
                database.AddOutParameter(cmd, "@connectionStringValue", DbType.AnsiString, 8000);
                database.ExecuteNonQuery(cmd);
                applicationConnectionString = (string)database.GetParameterValue(cmd, "@connectionStringValue");
            }

            return(applicationConnectionString);
        }