Exemplo n.º 1
0
        public static DataSet GetDataSetByName(string StoredProcedureName, params object[] paramlist)
        {
            ProcedureDefinition oProc = StoredProcedures.GetProcedureDefinition(StoredProcedureName);
            SQLUtil             utils = new SQLUtil();
            DataSet             ds    = new DataSet();

            if (!Object.Equals(paramlist, null))
            {
                foreach (KeyValuePair <string, object> param in paramlist)
                {
                    utils.AddParameter(param.Key, param.Value);
                }
            }

            ds = utils.ExecuteDataSet(oProc.FullyQualifiedCommand, oProc.Connection);
            if (Object.Equals(ds, null) || ds.Tables.Count <= 0)
            {
                ds = null;
            }

            return(ds);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes storedprocedure with a datatable as a parameter (for bulk merges)
        /// </summary>
        /// <param name="procname"></param>
        /// <param name="dt"></param>
        public static void ExecuteNonQueryTable(string procname, DataTable dt)
        {
            ProcedureDefinition oProc = StoredProcedures.GetProcedureDefinition(procname);

            using (SqlConnection con = new SqlConnection(GetConnection(oProc)))
            {
                try
                {
                    con.Open();

                    SqlCommand sqlCmd = new SqlCommand(oProc.FullyQualifiedCommand, con);
                    sqlCmd.CommandType = CommandType.StoredProcedure;
                    SqlParameter tvpParam = sqlCmd.Parameters.AddWithValue("@TableVariable", dt);
                    tvpParam.SqlDbType = SqlDbType.Structured;
                    sqlCmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw;
                }
            }
        }