Пример #1
0
        public static string SQLDebug(string sql)
        {
            sql = Tools.NullToString(sql);
            if (sql.Length < 3)
            {
                return("Invalid SQL" + (sql.Length > 0 ? " (" + sql + ")" : ""));
            }

            DBConn        conn = null;
            StringBuilder ret  = new StringBuilder();
            string        str  = "SQL = " + sql;

            try
            {
                Tools.LogInfo("Tools.SQLDebug/2", str, 255);
                ret.Append(str + Constants.C_HTMLBREAK());

                Tools.OpenDB(ref conn);

                if (conn.Execute(sql))
                {
                    str = "Execution successful, column count = " + conn.ColumnCount.ToString() + (conn.EOF ? " (NO rows)" : " (At least one row)");
                    Tools.LogInfo("Tools.SQLDebug/3", str, 255);
                    ret.Append(str + "<hr />");                   // Constants.C_HTMLBREAK());

                    string colType;

                    for (int k = 0; k < conn.ColumnCount; k++)
                    {
                        str = "(Col " + k.ToString()
                              + ") Name = " + conn.ColName(k)
                              + ", Type = " + conn.ColDataType("", k)
                              + ", Value = ";
                        colType = conn.ColDataType("", k).ToUpper();
                        if (conn.ColStatus("", k) == Constants.DBColumnStatus.ValueIsNull)
                        {
                            str = str + "NULL";
                        }
                        else if (colType == "NVARCHAR" || colType == "NCHAR")
                        {
                            str = str + conn.ColUniCode("", 0, k);
                        }
                        else
                        {
                            str = str + conn.ColValue(k);
                        }
                        Tools.LogInfo("Tools.SQLDebug/4", str, 255);
                        ret.Append(str + Constants.C_HTMLBREAK());
                    }
                }
                else
                {
                    str = "Execution failed";
                    Tools.LogInfo("Tools.SQLDebug/5", str, 255);
                    ret.Append(str + Constants.C_HTMLBREAK());
                }
            }
            catch (Exception ex)
            {
                str = "Error : " + ex.Message;
                Tools.LogInfo("Tools.SQLDebug/6", str, 255);
                ret.Append(str + Constants.C_HTMLBREAK());
            }
            finally
            {
                Tools.CloseDB(ref conn);
            }
            return(ret.ToString());
        }
Пример #2
0
 public override void LoadData(DBConn dbConn)
 {
 }           // Just because it has to be here ...