Example #1
0
 private void addParameters(SqlCommand cmd, SqlDataItem sqlDataItem)
 {
     if (sqlDataItem.ParameterList == null)
     {
         return;
     }
     foreach (SqlDataParameter param in sqlDataItem.ParameterList)
     {
         cmd.Parameters.Add(new SqlParameter(buildParameterName(param.ParameterName), param.ParameterValue));
     }
 }
Example #2
0
        public bool ExistSql_bool(SqlDataItem sqlDataItem)
        {
            DataTable dt = ExeSql_DT(sqlDataItem);

            if (dt != null && dt.Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
 public static DataTable getTable(SqlDataItem item, string accountName)
 {
     try
     {
         DataSql   agent = new DataSql(accountName);
         DataTable dt    = agent.ExeSql_DT(item);
         agent.Close();
         return(dt);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #4
0
 public string ExeSql_string(SqlDataItem sqlDataItem)
 {
     try
     {
         cmd.CommandType = Common.GetCommandType(sqlDataItem.CommandType);;
         cmd.CommandText = sqlDataItem.CommandText;
         addParameters(cmd, sqlDataItem);
         string result = cmd.ExecuteScalar().ToString();
         return(result);
     }
     catch (Exception ex)
     {
         Close();
         throw ex;
     }
 }
Example #5
0
 public int ExeSql_int(SqlDataItem sqlDataItem)
 {
     try
     {
         cmd.CommandType = Common.GetCommandType(sqlDataItem.CommandType);;
         cmd.CommandText = sqlDataItem.CommandText;
         addParameters(cmd, sqlDataItem);
         int t = cmd.ExecuteNonQuery();
         return(t);
     }
     catch (Exception ex)
     {
         Close();
         throw ex;
     }
 }
Example #6
0
 public void ExeSql_void(SqlDataItem sqlDataItem)
 {
     try
     {
         Open();
         cmd.CommandType = Common.GetCommandType(sqlDataItem.CommandType);
         cmd.CommandText = sqlDataItem.CommandText;
         addParameters(cmd, sqlDataItem);
         cmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         Close();
         throw ex;
     }
 }
Example #7
0
 public static DataTable getTable(string SQLstr, string accountName)
 {
     try
     {
         SqlDataItem item = new SqlDataItem();
         item.CommandText = SQLstr;
         DataSql   agent = new DataSql(accountName);
         DataTable dt    = agent.ExeSql_DT(item);
         agent.Close();
         return(dt);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #8
0
 private int executeNonQuery(SqlCommand cmd, SqlDataItem sqlDataItem)
 {
     //if (cmd == null) throw new ArgumentNullException("Sql Command");
     cmd.Parameters.Clear();
     try
     {
         Open();
         cmd.CommandText = sqlDataItem.CommandText;
         cmd.CommandType = Common.GetCommandType(sqlDataItem.CommandType);
         addParameters(cmd, sqlDataItem);
         return(cmd.ExecuteNonQuery());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #9
0
        public static void ExecVoid(string sqlstr, string accountName)
        {
            DataSql agent = new DataSql(accountName);

            try
            {
                SqlDataItem item = new SqlDataItem();
                item.CommandText = sqlstr;
                agent.ExeSql_void(item);
                agent.Close();
            }
            catch (Exception ee)
            {
                agent.Close();
                throw ee;
            }
        }
Example #10
0
 public static bool ExecSQL(SqlDataItem item, string accountName)
 {
     try
     {
         DataSql agent  = new DataSql(accountName);
         int     result = agent.ExeSql_int(item);
         if (result > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #11
0
        public DataTable ExeSql_DT(SqlDataItem sqlDataItem)
        {
            Open();
            DataTable      dt = new DataTable("data");
            SqlDataAdapter ad = new SqlDataAdapter();

            cmd.CommandType = Common.GetCommandType(sqlDataItem.CommandType);
            cmd.CommandText = sqlDataItem.CommandText;
            try
            {
                addParameters(cmd, sqlDataItem);
                ad.SelectCommand = cmd;
                ad.Fill(dt);
                ad.Dispose();
                return(dt);
            }
            catch (Exception ee)
            {
                Close();
                throw ee;
            }
        }
Example #12
0
 public void AppendSqlItem(SqlDataItem item)
 {
     sqlDataItemList.Add(item);
 }