Example #1
0
        /// <summary>
        /// inicjalizuje autocomplete i przekazuej do okreslonego okna
        /// </summary>
        /// <returns></returns>
        public static List <string[]> autoComplete(ref zenQuery.DbClient _dbClient)
        {
            if (string.Compare(_dbClient.providerr.ToString(), "mssql", true) != 0)
            {
                return(null);
            }

            // Hashtable items =new Hashtable();
            DataSet ds = _dbClient.Execute("select COLUMN_NAME  ,table_name from INFORMATION_SCHEMA.COLUMNS where TABLE_CATALOG = db_name() order by table_name,column_name  ", _dbClient.Connection.ConnectionTimeout);

            if (ds == null || ds.Tables.Count == 0)
            {
                return(null);
            }

            List <string[]> a = new List <string[]>();

            //Wypelnienie musi byc table_name, column_name
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                string[] arr = new string[2];
                arr[0] = row["table_name"].ToString();
                arr[1] = row["column_name"].ToString();
                a.Add(arr);
            }
            return(a);
        }
Example #2
0
        /// <summary>
        /// Komenda do tekstu
        /// </summary>
        /// <param name="sqlcommand"></param>
        /// <returns></returns>
        public static string getactionTextSqlParam(string sqlcommand, string options, ref zenQuery.DbClient _dbClient)
        {
            mk.Logic.simpleDebug.dump();
            try
            {
                string   prefix, sufix;
                bool     removePrefix, removeSufix;
                string[] strArr = options.Split('|');


                prefix       = NZ(strArr[0]);
                sufix        = NZ(strArr[1]);
                removePrefix = Convert.ToBoolean(strArr[2]);
                removeSufix  = Convert.ToBoolean(strArr[3]);



                DataSet ds = _dbClient.Execute(sqlcommand, 7);
                if (ds == null || ds.Tables.Count == 0)
                {
                    return("/* \n No rows returned from Action. Prepared command \n " + sqlcommand + "\n*/");
                }

                StringBuilder sb = new StringBuilder();


                int items     = ds.Tables[0].Rows.Count;
                int numerator = 0;

                string pattern;
                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    numerator++;
                    pattern = "";

                    if (numerator == 1 && removePrefix)
                    {
                        pattern = "";
                    }
                    else
                    {
                        pattern = "{0}";
                    }


                    pattern += "{1}";

                    if (items == numerator && removeSufix)
                    {
                        pattern += "";
                    }
                    else
                    {
                        pattern += "{2}";
                    }

                    sb.Append(string.Format(pattern, prefix, r[0].ToString(), sufix));
                }
                ds.Dispose();


                if (items == 0)
                {
                    sb.Append("/* \n No rows returned from Action. Prepared command \n " + sqlcommand + "\n*/");
                }

                sb.Replace("\n", Environment.NewLine);

                return(sb.ToString().Trim());
            }
            catch (Exception e)
            {
                return("ERROR " + e.Message.ToString());
            }
        }