Ejemplo n.º 1
0
        public int InsertByHashtable(string tableName, Hashtable paramlist)
        {
            StringBuilder sb        = new StringBuilder("insert into {0}({1}) values({2})");
            StringBuilder sbColumns = new StringBuilder();
            StringBuilder sbValues  = new StringBuilder();

            foreach (DictionaryEntry item in paramlist)
            {
                if (sbColumns.Length == 0)
                {
                    sbColumns.Append(item.Key);
                }
                else
                {
                    sbColumns.Append("," + item.Key);
                }
                if (sbValues.Length == 0)
                {
                    sbValues.Append("@" + item.Key);
                }
                else
                {
                    sbValues.Append(",@" + item.Key);
                }
            }
            string sql = string.Format("insert into {0}({1}) values({2})", tableName, sbColumns.ToString(), sbValues.ToString());

            return(DbHelperSQL2.ExecuteSql(sql, paramlist));
        }
Ejemplo n.º 2
0
        public int InsertTable(Hashtable ht, string tableName)
        {
            StringBuilder sb    = new StringBuilder();
            StringBuilder sbVal = new StringBuilder();

            foreach (DictionaryEntry item in ht)
            {
                sb.AppendFormat("{0},", item.Key);
                sbVal.AppendFormat("@{0},", item.Key);
            }
            string InsertSql = string.Format("insert into {0}({1}) values({2})", tableName, sb.ToString().Trim(','), sbVal.ToString().Trim(','));

            return(DbHelperSQL2.ExecuteSql(InsertSql, ht));
        }
Ejemplo n.º 3
0
        public int UpdateTable(Hashtable ht, string tableName, string idName = "id")
        {
            StringBuilder sb = new StringBuilder();

            foreach (DictionaryEntry item in ht)
            {
                if (!item.Key.ToString().Equals(idName, StringComparison.CurrentCultureIgnoreCase))
                {
                    sb.AppendFormat(" {0} = @{0},", item.Key);
                }
            }
            string UpdateSql = string.Format("update {0} set {1} where {2}=@{2}", tableName, sb.ToString().Trim(','), idName);

            return(DbHelperSQL2.ExecuteSql(UpdateSql, ht));
        }
Ejemplo n.º 4
0
 public int UID(string sql, Hashtable pararm = null)
 {
     //   SqlParameter[] parameters = BuildSqlParameters(pararm);
     return(DbHelperSQL2.ExecuteSql(sql, pararm));
 }
Ejemplo n.º 5
0
 public int UID(string Sql)
 {
     return(DbHelperSQL2.ExecuteSql(Sql));
 }