using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Stock.BLL;
using System.Text.RegularExpressions;
using System.Xml;
using System.Data.SqlClient;
using System.Web;
namespace Stock.DAL
{
public class taobao
{
private static string shopSearchUrl = "http://s.taobao.com/search?q={0}&app=shopsearch";
private static string taobaoItemPhoneUrl = "http://a.m.tmall.com/i{0}.htm";
private static string GoodsKeywordSearchUrl = "{0}/search.htm?search=y&keyword={1}&pageNum={2}&pageNo={2}";
/// <summary>
/// 获取店铺url
/// </summary>
/// <param name="shopname"></param>
/// <returns></returns>
public static string GetShopUrl(string shopname)
{
try
{
string sUrl = string.Format(shopSearchUrl, shopname);
string Content = WebRequest.GetWebRequest(sUrl);
if (Content != "")
{
Match TideMatch = Regex.Match(Content, "<a trace="shop" data-uid=((\w|\W)*?)</a>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
var A = TideMatch.Value;
if (A.Trim() != "")
{
var index1 = A.IndexOf(".taobao.com");
var index2 = A.IndexOf("http://");
return A.Substring(index2, index1 - index2 + 11);
}
else return "";
}
return "";
}
catch (Exception e)
{
LogHelp.Error("获取店铺url:" + e.ToString());
return "";
}
}
/// <summary>
/// 获取淘宝成交记录
/// </summary>
public static List<Deal> GetDealistFromTaobao(string onlineGoodId, string url, string lastDealTime, string buyer, string keyword)
{
DateTime tempD = DateTime.Now.AddHours(1);
string _buyer = "";
List<Deal> deals = new List<Deal>();
string Content = WebRequest.GetWebRequest(url, null, null, null, "GET");
var goodTitle = GetGoodTitle(Content);
if (goodTitle != "" && keyword.Trim() != "" && goodTitle.IndexOf(keyword) < 0) return deals;
Match TideMatch = Regex.Match(Content, "<button id="J_listBuyerOnView" type="button"((\w|\W)*?)</button>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
var html = TideMatch.Value;
if (html != "")
{
try
{
int pageIndex = 1;
int index1 = html.IndexOf("http://");
int index2 = html.IndexOf("&msc=1");
string DealUrl = html.Substring(index1, index2 - index1 + 6);
DealUrl = DealUrl.Replace("&bid_page=1&", "&bid_page={0}&") + "&callback=Hub.data.records_reload";
bool hasMore = false;
while (pageIndex <= 100)
{
string dealListCont = WebRequest.GetWebRequest(string.Format(DealUrl, pageIndex), url);
if (dealListCont.IndexOf("买家出价记录") >= 0)
{
//进入查看更多模式
if (pageIndex == 1 && !hasMore)
{
var index = dealListCont.IndexOf("<p class=\"tb-view-all\">");
if (index >= 0)
{
string more = dealListCont.Substring(index);
index = more.IndexOf("http://detailskip.taobao.com/json/show_buyer_list.htm");
var _index = more.IndexOf(",showBuyerList");
more = more.Substring(index, _index - index).Replace("amp;", "");
more = more.Replace("bid_page=1&", "bid_page={0}&") + "&callback=Hub.data.records_reload";
DealUrl = more;
}
hasMore = true;
continue;
}
//有成交记录
TideMatch = Regex.Match(dealListCont, "<table((\w|\W)*?)</table>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
XmlDocument Doc = new XmlDocument();
var txt = TideMatch.Value.Replace("\", "").Replace(""", "'").Replace("tb-anonymous", "'tb-anonymous'").Replace("¥", "¥");
Regex r = new Regex("<img((\w|\W)*?)>");
txt = r.Replace(txt, "");
Doc.LoadXml(txt);
XmlNodeList _list = Doc.GetElementsByTagName("tr");
foreach (XmlElement e in _list)
{
try
{
Deal _deal = new Deal();
_deal.goodId = onlineGoodId;
XmlNodeList tdlist = e.GetElementsByTagName("td");
if (tdlist.Count > 0)
{
foreach (XmlElement td in tdlist)
{
var _class = td.GetAttribute("class");
switch (_class)
{
case "tb-buyer": _deal.buyer = td.InnerText; break;
case "tb-amount": _deal.num = td.InnerText; break;
case "tb-start":
{
_deal.buyTime = td.InnerText;
break;
}
case "tb-price":
{
var A = td.GetElementsByTagName("a");
if (A != null && A.Count > 0)
{
_deal.promotionTitle = (A[0] as XmlElement).GetAttribute("title");
}
else _deal.promotionTitle = "";
var price = td.InnerText.Replace("¥", "");
decimal dPrice = 0;
if (decimal.TryParse(price, out dPrice))
{
_deal.price = dPrice.ToString();
}
break;
}
case "tb-sku":
{
var span = td.GetElementsByTagName("span");
if (span != null && span.Count > 0)
{
_deal.goodName = (span[0] as XmlElement).GetAttribute("data-title");
if (keyword.Trim() != "")
{
if (!(_deal.goodName != null && _deal.goodName.IndexOf(keyword) >= 0))
{
_deal = null;
break;
}
}
}
else _deal.goodName = goodTitle;
break;
}
}
if (_deal == null) break;
}
if (_deal == null) continue;
if ((_buyer != "" && Convert.ToDateTime(_deal.buyTime) == tempD && _buyer == _deal.buyer)) return deals;
if (_deal != null)
{
if (lastDealTime != null && lastDealTime.Trim() != "" && Convert.ToDateTime(_deal.buyTime) < Convert.ToDateTime(lastDealTime))
{
return deals;
}
if (lastDealTime != null && lastDealTime.Trim() != "" && Convert.ToDateTime(_deal.buyTime) == Convert.ToDateTime(lastDealTime) && _deal.buyer == buyer)
{
return deals;
}
if (_deal.buyer != null && _deal.buyer.ToString() != "")
{
if (deals.Count == 0)
{
tempD = Convert.ToDateTime(_deal.buyTime);
_buyer = _deal.buyer;
}
deals.Add(_deal);
}
}
}
}
catch (Exception ex)
{
LogHelp.Error("获取淘宝宝贝成交记录:" + ex.ToString() + "/r/n content" + e.InnerXml);
}
}
if (_list.Count < 15) return deals;
pageIndex++;
}
else break;
}
}
catch { }
}
return deals;
}
/// <summary>
/// 获取天猫触屏版价格
/// </summary>
/// <param name="goodid"></param>
/// <returns></returns>
public static string GetGoodPhonePrice(string goodid)
{
try
{
string price = "0.00";
string content = WebRequest.GetWebRequest(string.Format(taobaoItemPhoneUrl, goodid), null, "1", "UTF-8");
string reg = "<b class="p-price-v">";
string reg1 = "<b class="o-price-v">";
string reg2 = ""promPrice":{";
int index = content.IndexOf(reg);
if (index < 0) index = content.IndexOf(reg1);
if (index >= 0)
{
content = content.Substring(index + reg.Length);
index = content.IndexOf("</b>");
if (index >= 0)
{
price = content.Substring(0, index);
}
}
else
{
index = content.IndexOf(reg2);
if (index >= 0)
{
content = content.Substring(index);
index = content.IndexOf("}");
if (index >= 0) content = content.Substring(0, index);
var reg3 = ""price":"";
index = content.IndexOf(reg3);
if (index >= 0) content = content.Substring(index + reg3.Length);
index = content.IndexOf(""");
if (index >= 0) price = content.Substring(0, index);
}
else
{
var reg3 = ""price":{"";
index = content.IndexOf(reg3);
if (index >= 0) content = content.Substring(index + reg3.Length);
index = content.IndexOf("}");
if (index >= 0) content = content.Substring(0, index);
reg3 = "amount":";
index = content.IndexOf(reg3);
if (index >= 0) content = content.Substring(index + reg3.Length);
index = content.IndexOf(",");
if (index >= 0) price = content.Substring(0, index);
}
}
if (price == "0.00")
{
LogHelp.Error("天猫触屏版价格:" + goodid);
}
decimal p = 0.00M;
if (decimal.TryParse(price, out p)) return price;
else return "0.00";
}
catch
{
return "0.00";
}
}
/// <summary>
/// 获取产品标题
/// </summary>
/// <param name="content"></param>
/// <returns></returns>
public static string GetGoodTitle(string content)
{
var title = "";
string reg = "<title>";
int index1 = content.IndexOf(reg);
if (index1 >= 0)
{
content = content.Substring(index1 + reg.Length);
index1 = content.IndexOf("</title>");
if (index1 > 0) title = content.Substring(0, index1);
title = title.Replace("<span class="H">", "").Replace("</span>", "").Trim();
return title;
}
else return title;
}
/// <summary>
/// 获取天猫成交记录
/// </summary>
public static List<Deal> GetDealistFromTM(string onlineNId, string goodid, string url, string lastDealTime, string buyer, string keyword)
{
DateTime tempD = DateTime.Now.AddHours(1);
string _buyer = "";
List<Deal> deals = new List<Deal>();
string Content = WebRequest.GetWebRequest(url, null, null, null, "GET");
var goodTitle = GetGoodTitle(Content);
if (goodTitle != "" && keyword.Trim() != "" && goodTitle.IndexOf(keyword) < 0) return deals;
var phonePrice = GetGoodPhonePrice(goodid);
Match TideMatch = Regex.Match(Content, "<button id="J_listBuyerOnView" type="button"((\w|\W)*?)</button>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
var html = TideMatch.Value;
if (html != "")
{
try
{
int pageIndex = 1;
string DealUrl = null;
int index1 = html.IndexOf("http://");
int index2 = html.IndexOf(",showBuyerList");
DealUrl = html.Substring(index1, index2 - index1);
DealUrl = DealUrl.Replace("bid_page=1&", "bid_page={0}&") + "&callback=Hub.data.records_reload";
bool hasMore = false;
while (pageIndex <= 100)
{
string dealListCont = WebRequest.GetWebRequest(string.Format(DealUrl, pageIndex), url);
if (dealListCont.IndexOf("成交记录") >= 0)
{
//进入查看更多模式
if (pageIndex == 1 && !hasMore)
{
var index = dealListCont.IndexOf("<p class=\"view-all\">");
if (index >= 0)
{
string more = dealListCont.Substring(index);
index = more.IndexOf("http://ext.mdskip.taobao.com/extension/dealRecords.htm");
var _index = more.IndexOf(",showBuyerList");
more = more.Substring(index, _index - index).Replace("amp;", "");
more = more.Replace("bidPgae=1&", "bid_page={0}&") + "&callback=Hub.data.records_reload";
DealUrl = more;
}
hasMore = true;
continue;
}
//有成交记录
TideMatch = Regex.Match(dealListCont, "<table((\w|\W)*?)</table>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
XmlDocument Doc = new XmlDocument();
var txt = TideMatch.Value.Replace("\", "").Replace(""", "'").Replace("tb-anonymous", "'tb-anonymous'").Replace("¥", "¥");
Regex r = new Regex("<img((\w|\W)*?)>");
txt = r.Replace(txt, "");
Doc.LoadXml(txt);
XmlNodeList _list = Doc.GetElementsByTagName("tr");
foreach (XmlElement e in _list)
{
try
{
Deal _deal = new Deal();
_deal.goodId = onlineNId;
XmlNodeList tdlist = e.GetElementsByTagName("td");
if (tdlist.Count > 0)
{
foreach (XmlElement td in tdlist)
{
string _class = td.GetAttribute("class");
if (_class.IndexOf("buyer") > 0) _class = "buyer";
else if (_class.IndexOf("style") > 0) _class = "style";
switch (_class)
{
case "buyer": _deal.buyer = td.InnerText; break;
case "style":
{
_deal.goodName = goodTitle;
break;
}
case "price":
{
var A = td.GetElementsByTagName("a");
if (A != null && A.Count > 0)
{
_deal.promotionTitle = (A[0] as XmlElement).GetAttribute("title");
}
else _deal.promotionTitle = "";
var price = td.InnerText.Replace("¥", "");
decimal dPrice = 0;
if (decimal.TryParse(price, out dPrice))
{
_deal.price = dPrice.ToString();
}
else
{
_deal.promotionTitle = td.InnerText;
if (_deal.promotionTitle == "手机专享") _deal.price = phonePrice;
else _deal.price = "0.00";
}
break;
}
case "quantity": _deal.num = td.InnerText; break;
case "dealtime":
{
string _time = td.InnerText;
if (_time.Substring(10, 1) != "")
{
_time = _time.Substring(0, 10) + " " + _time.Substring(10);
}
_deal.buyTime = _time;
break;
}
}
}
if (_buyer != "" && Convert.ToDateTime(_deal.buyTime) == tempD && _buyer == _deal.buyer) return deals;
if (lastDealTime != null && lastDealTime.Trim() != "" && Convert.ToDateTime(_deal.buyTime) < Convert.ToDateTime(lastDealTime))
{
return deals;
}
if (lastDealTime != null && lastDealTime.Trim() != "" && Convert.ToDateTime(_deal.buyTime) == Convert.ToDateTime(lastDealTime) && _deal.buyer == buyer)
{
return deals;
}
if (_deal.buyer != null && _deal.buyer.ToString() != "")
{
if (deals.Count == 0)
{
tempD = Convert.ToDateTime(_deal.buyTime);
_buyer = _deal.buyer;
}
deals.Add(_deal);
}
}
}
catch (Exception ex)
{
LogHelp.Error("获取天猫宝贝成交记录:" + ex.ToString() + "/r/n content" + e.InnerXml);
}
}
if (_list.Count < 15) return deals;
pageIndex++;
}
else break;
}
}
catch (Exception e)
{
LogHelp.Error("GetDealistFromTM:" + e.ToString());
}
}
return deals;
}
/// <summary>
/// 获取淘宝店铺商品
/// </summary>
public static List<Item> GetGoodsFromTaobo(string shopUrl, string keyword, string shopId)
{
List<Item> _items = new List<Item>();
int pageIndex = 1;
while (true)
{
string _url = string.Format(GoodsKeywordSearchUrl, shopUrl, System.Web.HttpUtility.UrlEncode(keyword, Encoding.GetEncoding("GBK")), pageIndex);
string Content = WebRequest.GetWebRequest(_url, shopUrl);
Match TideMatch = Regex.Match(Content, "class="shop-hesper-bd grid"((\w|\W)*?)<script", RegexOptions.IgnoreCase | RegexOptions.Multiline);
if (TideMatch.Value.Length == 0)
TideMatch = Regex.Match(Content, "id="TmshopSrchNav"((\w|\W)*?)<script", RegexOptions.IgnoreCase | RegexOptions.Multiline);
//淘宝店
if (TideMatch.Value.Length > 0)
{
Content = TideMatch.Value;
MatchCollection Items = Regex.Matches(Content, "class="detail((\w|\W)*?)</div>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
if (Items == null || Items.Count == 0)
Items = Regex.Matches(Content, "class="detail((\w|\W)*?)</dd>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
if (Items == null || Items.Count == 0)
Items = Regex.Matches(Content, "class="desc((\w|\W)*?)</div>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
if (Items == null || Items.Count == 0)
Items = Regex.Matches(Content, "class="desc((\w|\W)*?)</dd>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
if (Items == null || Items.Count == 0) return _items;
if (Content.IndexOf("class="item-not-found"") >= 0) return _items;
if ((Items == null || Items.Count == 0) && Content.IndexOf("没有对应的宝贝") >= 0) return _items;
foreach (Match M in Items)
{
try
{
Item _it = new Item();
_it.shopId = shopId;
var A = M.Value;
var index1 = A.IndexOf("href="");
var index2 = -1;
if (index1 < 0)
{
index1 = A.IndexOf("href='");
if (index1 >= 0)
{
A = A.Substring(index1 + 6);
index2 = A.IndexOf("'");
_it.url = A.Substring(0, index2);
}
else
{
index1 = A.IndexOf("href=");
if (index1 < 0) continue;
A = A.Substring(index1 + 8);
index2 = A.IndexOf(" ");
_it.url = A.Substring(0, index2);
}
}
else
{
A = A.Substring(index1 + 6);
index2 = A.IndexOf(""");
_it.url = A.Substring(0, index2);
}
index1 = A.IndexOf(">");
index2 = A.IndexOf("</a>");
_it.title = A.Substring(index1 + 1, index2 - index1 - 1);
if (_it.title.IndexOf(keyword) < 0) continue;
string _Nid = _it.url;
if (_Nid.IndexOf("&id=") < 0 && _Nid.IndexOf("?id=") < 0)
{
continue;
}
if (_Nid.IndexOf("&id=") > 0) _Nid = _Nid.Substring(_Nid.IndexOf("&id=") + 4) + "&";
else _Nid = _Nid.Substring(_Nid.IndexOf("?id=") + 4) + "&";
_Nid = _Nid.Substring(0, _Nid.IndexOf("&"));
_it.id = _Nid;
_items.Add(_it);
}
catch (Exception ex) { LogHelp.Error("获取淘宝店铺商品" + ex.ToString()); }
}
pageIndex++;
}
else return _items;
}
}
public static string BuildShopId(string constr)
{
object val = SqlHelper.ExecuteScalar(constr, CommandType.Text, "select max(shopId) from sys_compayPlatFormShop");
if (val == null || val.ToString() == "") return "1";
else return (Convert.ToInt16(val) + 1).ToString();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
namespace Stock.BLL
{
public class WebRequest
{
public static string GetWebRequest(string url, string Referer = null, string userAgent = null, string code = null, string Method=null)
{
try
{
StringBuilder sbTideHTML = new StringBuilder();
Uri uri = new Uri(url);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.Timeout = 10000;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1";
request.Method = "POST";
if (Referer != null) request.Referer = Referer;
if (Method != null) request.Method = Method;
if (userAgent != null)
{
//苹果iPhone
request.UserAgent = "Mozilla/5.0 (iPad; U; CPU OS 3_2_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B500 Safari/531.21.10";
}
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
Encoding encoding = Encoding.GetEncoding("GBK");
if (code != null) encoding = Encoding.GetEncoding(code);
using (StreamReader myStreamReader = new StreamReader(response.GetResponseStream(), encoding))
{
string html = myStreamReader.ReadToEnd();
return html;
}
}
}
catch
{
return "";
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Collections;
using System.Data;
using System.Xml;
using GotDotNet.ApplicationBlocks.Data;
namespace Stock.BLL
{
public sealed class SqlHelper
{
/// <summary>
/// Calls the SqlCommandBuilder.DeriveParameters, doing any setup and cleanup necessary
/// </summary>
/// <param name="cmd">The SqlCommand referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the Parameters collection of the SqlCommand. </param>
public static void DeriveParameters(SqlCommand cmd)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().DeriveParameters(cmd);
}
public static DataSet RunProcedure(string storedProcName, IDataParameter[] parameters, string tableName, string connectionString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
DataSet dataSet = new DataSet();
connection.Open();
SqlDataAdapter sqlDA = new SqlDataAdapter();
try
{
sqlDA.SelectCommand = BuildQueryCommand(connection, storedProcName, parameters);
sqlDA.Fill(dataSet, tableName);
connection.Close();
return dataSet;
}
catch (Exception ex)
{ throw ex; }
}
}
private static SqlCommand BuildQueryCommand(SqlConnection connection, string storedProcName, IDataParameter[] parameters)
{
SqlCommand command = new SqlCommand(storedProcName, connection);
command.CommandType = CommandType.StoredProcedure;
foreach (SqlParameter parameter in parameters)
{
if (parameter != null)
{
// 检查未分配值的输出参数,将其分配以DBNull.Value.
if ((parameter.Direction == ParameterDirection.InputOutput || parameter.Direction == ParameterDirection.Input) &&
(parameter.Value == null))
{
parameter.Value = DBNull.Value;
}
command.Parameters.Add(parameter);
}
}
return command;
}
#region Private constructor
// Since this class provides only static methods, make the default constructor private to prevent
// instances from being created with "new SqlHelper()"
private SqlHelper() { }
#endregion Private constructor
#region GetParameter
/// <summary>
/// Get a SqlParameter for use in a SQL command
/// </summary>
/// <param name="name">The name of the parameter to create</param>
/// <param name="value">The value of the specified parameter</param>
/// <returns>A SqlParameter object</returns>
public static SqlParameter GetParameter(string name, object value)
{
return (SqlParameter)(new GotDotNet.ApplicationBlocks.Data.SqlServer().GetParameter(name, value));
}
/// <summary>
/// Get a SqlParameter for use in a SQL command
/// </summary>
/// <param name="name">The name of the parameter to create</param>
/// <param name="dbType">The System.Data.DbType of the parameter</param>
/// <param name="size">The size of the parameter</param>
/// <param name="direction">The System.Data.ParameterDirection of the parameter</param>
/// <returns>A SqlParameter object</returns>
public static SqlParameter GetParameter(string name, DbType dbType, int size, ParameterDirection direction)
{
return (SqlParameter)(new GotDotNet.ApplicationBlocks.Data.SqlServer().GetParameter(name, dbType, size, direction));
}
/// <summary>
/// Get a SqlParameter for use in a SQL command
/// </summary>
/// <param name="name">The name of the parameter to create</param>
/// <param name="dbType">The System.Data.DbType of the parameter</param>
/// <param name="size">The size of the parameter</param>
/// <param name="sourceColumn">The source column of the parameter</param>
/// <param name="sourceVersion">The System.Data.DataRowVersion of the parameter</param>
/// <returns>A SqlParameter object</returns>
public static SqlParameter GetParameter(string name, DbType dbType, int size, string sourceColumn, DataRowVersion sourceVersion)
{
return (SqlParameter)new GotDotNet.ApplicationBlocks.Data.SqlServer().GetParameter(name, dbType, size, sourceColumn, sourceVersion);
}
#endregion
#region ExecuteNonQuery
/// <summary>
/// Execute a SqlCommand (that returns no resultset) against the database specified in
/// the connection string
/// </summary>
/// <remarks>
/// e.g.:
/// int result = ExecuteNonQuery(command);
/// </remarks>
/// <param name="command">The SqlCommand to execute</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(SqlCommand command)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQuery(command);
}
/// <summary>
/// Execute a SqlCommand (that returns no resultset and takes no parameters) against the database specified in
/// the connection string
/// </summary>
/// <remarks>
/// e.g.:
/// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders");
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQuery(connectionString, commandType, commandText);
}
/// <summary>
/// Execute a SqlCommand (that returns no resultset) against the database specified in the connection string
/// using the provided parameters
/// </summary>
/// <remarks>
/// e.g.:
/// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQuery(connectionString, commandType, commandText, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns no resultset) against the database specified in
/// the connection string using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// int result = ExecuteNonQuery(connString, "PublishOrders", 24, 36);
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="spName">The name of the stored prcedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(string connectionString, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQuery(connectionString, spName, parameterValues);
}
/// <summary>
/// Execute a SqlCommand (that returns no resultset and takes no parameters) against the provided SqlConnection.
/// </summary>
/// <remarks>
/// e.g.:
/// int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders");
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQuery(connection, commandType, commandText);
}
/// <summary>
/// Execute a SqlCommand (that returns no resultset) against the specified SqlConnection
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQuery(connection, commandType, commandText, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified SqlConnection
/// using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// int result = ExecuteNonQuery(conn, "PublishOrders", 24, 36);
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(SqlConnection connection, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQuery(connection, spName, parameterValues);
}
/// <summary>
/// Execute a SqlCommand (that returns no resultset and takes no parameters) against the provided SqlTransaction.
/// </summary>
/// <remarks>
/// e.g.:
/// int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "PublishOrders");
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQuery(transaction, commandType, commandText);
}
/// <summary>
/// Execute a SqlCommand (that returns no resultset) against the specified SqlTransaction
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQuery(transaction, commandType, commandText, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified
/// SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// int result = ExecuteNonQuery(conn, trans, "PublishOrders", 24, 36);
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(SqlTransaction transaction, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQuery(transaction, spName, parameterValues);
}
#endregion ExecuteNonQuery
#region ExecuteDataset
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the database specified in
/// the connection string.
/// </summary>
/// <remarks>
/// e.g.:
/// DataSet ds = ExecuteDataset(command);
/// </remarks>
/// <param name="command">The SqlCommand to execute</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDataset(SqlCommand command)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDataset(command);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in
/// the connection string.
/// </summary>
/// <remarks>
/// e.g.:
/// DataSet ds = ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders");
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDataset(connectionString, commandType, commandText);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the database specified in the connection string
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// DataSet ds = ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDataset(connectionString, commandType, commandText, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in
/// the connection string using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// DataSet ds = ExecuteDataset(connString, "GetOrders", 24, 36);
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDataset(string connectionString, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDataset(connectionString, spName, parameterValues);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.
/// </summary>
/// <remarks>
/// e.g.:
/// DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders");
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDataset(connection, commandType, commandText);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the specified SqlConnection
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDataset(connection, commandType, commandText, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
/// using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// DataSet ds = ExecuteDataset(conn, "GetOrders", 24, 36);
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDataset(SqlConnection connection, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDataset(connection, spName, parameterValues);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.
/// </summary>
/// <remarks>
/// e.g.:
/// DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders");
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDataset(SqlTransaction transaction, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDataset(transaction, commandType, commandText);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the specified SqlTransaction
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDataset(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDataset(transaction, commandType, commandText, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified
/// SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// DataSet ds = ExecuteDataset(trans, "GetOrders", 24, 36);
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDataset(SqlTransaction transaction, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDataset(transaction, spName, parameterValues);
}
#endregion ExecuteDataset
#region ExecuteReader
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the database specified in
/// the connection string.
/// </summary>
/// <remarks>
/// e.g.:
/// SqlDataReader dr = ExecuteReader(command);
/// </remarks>
/// <param name="command">The SqlCommand to execute</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReader(SqlCommand command)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReader(command) as SqlDataReader;
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in
/// the connection string.
/// </summary>
/// <remarks>
/// e.g.:
/// SqlDataReader dr = ExecuteReader(connString, CommandType.StoredProcedure, "GetOrders");
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReader(connectionString, commandType, commandText) as SqlDataReader;
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the database specified in the connection string
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// SqlDataReader dr = ExecuteReader(connString, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReader(connectionString, commandType, commandText, commandParameters) as SqlDataReader;
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in
/// the connection string using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// SqlDataReader dr = ExecuteReader(connString, "GetOrders", 24, 36);
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReader(string connectionString, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReader(connectionString, spName, parameterValues) as SqlDataReader;
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.
/// </summary>
/// <remarks>
/// e.g.:
/// SqlDataReader dr = ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders");
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReader(SqlConnection connection, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReader(connection, commandType, commandText) as SqlDataReader;
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the specified SqlConnection
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// SqlDataReader dr = ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReader(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReader(connection, commandType, commandText, commandParameters) as SqlDataReader;
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
/// using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// SqlDataReader dr = ExecuteReader(conn, "GetOrders", 24, 36);
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReader(SqlConnection connection, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReader(connection, spName, parameterValues) as SqlDataReader;
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.
/// </summary>
/// <remarks>
/// e.g.:
/// SqlDataReader dr = ExecuteReader(trans, CommandType.StoredProcedure, "GetOrders");
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReader(SqlTransaction transaction, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReader(transaction, commandType, commandText) as SqlDataReader;
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the specified SqlTransaction
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// SqlDataReader dr = ExecuteReader(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReader(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReader(transaction, commandType, commandText, commandParameters) as SqlDataReader;
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified
/// SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// SqlDataReader dr = ExecuteReader(trans, "GetOrders", 24, 36);
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReader(SqlTransaction transaction, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReader(transaction, spName, parameterValues) as SqlDataReader;
}
#endregion ExecuteReader
#region ExecuteScalar
/// <summary>
/// Execute a SqlCommand (that returns a 1x1 resultset) against the database specified in
/// the connection string.
/// </summary>
/// <remarks>
/// e.g.:
/// int orderCount = (int)ExecuteScalar(command);
/// </remarks>
/// <param name="command">The SqlCommand to execute</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalar(SqlCommand command)
{
// Pass through the call providing null for the set of SqlParameters
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalar(command);
}
/// <summary>
/// Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the database specified in
/// the connection string.
/// </summary>
/// <remarks>
/// e.g.:
/// int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount");
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalar(string connectionString, CommandType commandType, string commandText)
{
// Pass through the call providing null for the set of SqlParameters
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalar(connectionString, commandType, commandText);
}
/// <summary>
/// Execute a SqlCommand (that returns a 1x1 resultset) against the database specified in the connection string
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalar(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalar(connectionString, commandType, commandText, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the database specified in
/// the connection string using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// int orderCount = (int)ExecuteScalar(connString, "GetOrderCount", 24, 36);
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalar(string connectionString, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalar(connectionString, spName, parameterValues);
}
/// <summary>
/// Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the provided SqlConnection.
/// </summary>
/// <remarks>
/// e.g.:
/// int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount");
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalar(SqlConnection connection, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalar(connection, commandType, commandText);
}
/// <summary>
/// Execute a SqlCommand (that returns a 1x1 resultset) against the specified SqlConnection
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalar(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalar(connection, commandType, commandText, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlConnection
/// using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// int orderCount = (int)ExecuteScalar(conn, "GetOrderCount", 24, 36);
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalar(SqlConnection connection, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalar(connection, spName, parameterValues);
}
/// <summary>
/// Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the provided SqlTransaction.
/// </summary>
/// <remarks>
/// e.g.:
/// int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount");
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalar(SqlTransaction transaction, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalar(transaction, commandType, commandText);
}
/// <summary>
/// Execute a SqlCommand (that returns a 1x1 resultset) against the specified SqlTransaction
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalar(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalar(transaction, commandType, commandText, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified
/// SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// int orderCount = (int)ExecuteScalar(trans, "GetOrderCount", 24, 36);
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalar(SqlTransaction transaction, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalar(transaction, spName, parameterValues);
}
#endregion ExecuteScalar
#region ExecuteXmlReader
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the provided SqlConnection.
/// </summary>
/// <remarks>
/// e.g.:
/// XmlReader r = ExecuteXmlReader(SqlCommand command);
/// </remarks>
/// <param name="command">The SqlCommand to execute</param>
/// <returns>An XmlReader containing the resultset generated by the command</returns>
public static XmlReader ExecuteXmlReader(SqlCommand command)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteXmlReader(command);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.
/// </summary>
/// <remarks>
/// e.g.:
/// XmlReader r = ExecuteXmlReader(conn, CommandType.StoredProcedure, "GetOrders");
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command using "FOR XML AUTO"</param>
/// <returns>An XmlReader containing the resultset generated by the command</returns>
public static XmlReader ExecuteXmlReader(SqlConnection connection, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteXmlReader(connection, commandType, commandText);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the specified SqlConnection
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// XmlReader r = ExecuteXmlReader(conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command using "FOR XML AUTO"</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>An XmlReader containing the resultset generated by the command</returns>
public static XmlReader ExecuteXmlReader(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteXmlReader(connection, commandType, commandText, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
/// using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// XmlReader r = ExecuteXmlReader(conn, "GetOrders", 24, 36);
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="spName">The name of the stored procedure using "FOR XML AUTO"</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>An XmlReader containing the resultset generated by the command</returns>
public static XmlReader ExecuteXmlReader(SqlConnection connection, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteXmlReader(connection, spName, parameterValues);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.
/// </summary>
/// <remarks>
/// e.g.:
/// XmlReader r = ExecuteXmlReader(trans, CommandType.StoredProcedure, "GetOrders");
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command using "FOR XML AUTO"</param>
/// <returns>An XmlReader containing the resultset generated by the command</returns>
public static XmlReader ExecuteXmlReader(SqlTransaction transaction, CommandType commandType, string commandText)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteXmlReader(transaction, commandType, commandText);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the specified SqlTransaction
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// XmlReader r = ExecuteXmlReader(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command using "FOR XML AUTO"</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>An XmlReader containing the resultset generated by the command</returns>
public static XmlReader ExecuteXmlReader(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteXmlReader(transaction, commandType, commandText, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified
/// SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// XmlReader r = ExecuteXmlReader(trans, "GetOrders", 24, 36);
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static XmlReader ExecuteXmlReader(SqlTransaction transaction, string spName, params object[] parameterValues)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteXmlReader(transaction, spName, parameterValues);
}
#endregion ExecuteXmlReader
#region FillDataset
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the database specified in
/// the connection string.
/// </summary>
/// <remarks>
/// e.g.:
/// FillDataset(connString, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
/// </remarks>
/// <param name="command">The SqlCommand to execute</param>
/// <param name="dataSet">A dataset wich will contain the resultset generated by the command</param>
/// <param name="tableNames">This array will be used to create table mappings allowing the DataTables to be referenced
/// by a user defined name (probably the actual table name)</param>
public static void FillDataset(SqlCommand command, DataSet dataSet, string[] tableNames)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().FillDataset(command, dataSet, tableNames);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in
/// the connection string.
/// </summary>
/// <remarks>
/// e.g.:
/// FillDataset(connString, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="dataSet">A dataset wich will contain the resultset generated by the command</param>
/// <param name="tableNames">This array will be used to create table mappings allowing the DataTables to be referenced
/// by a user defined name (probably the actual table name)</param>
public static void FillDataset(string connectionString, CommandType commandType, string commandText, DataSet dataSet, string[] tableNames)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().FillDataset(connectionString, commandType, commandText, dataSet, tableNames);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the database specified in the connection string
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// FillDataset(connString, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <param name="dataSet">A dataset wich will contain the resultset generated by the command</param>
/// <param name="tableNames">This array will be used to create table mappings allowing the DataTables to be referenced
/// by a user defined name (probably the actual table name)
/// </param>
public static void FillDataset(string connectionString, CommandType commandType,
string commandText, DataSet dataSet, string[] tableNames,
params SqlParameter[] commandParameters)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().FillDataset(connectionString, commandType, commandText, dataSet, tableNames, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in
/// the connection string using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// FillDataset(connString, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, 24);
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataSet">A dataset wich will contain the resultset generated by the command</param>
/// <param name="tableNames">This array will be used to create table mappings allowing the DataTables to be referenced
/// by a user defined name (probably the actual table name)
/// </param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
public static void FillDataset(string connectionString, string spName,
DataSet dataSet, string[] tableNames, params object[] parameterValues)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().FillDataset(connectionString, spName, dataSet, tableNames, parameterValues);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.
/// </summary>
/// <remarks>
/// e.g.:
/// FillDataset(conn, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="dataSet">A dataset wich will contain the resultset generated by the command</param>
/// <param name="tableNames">This array will be used to create table mappings allowing the DataTables to be referenced
/// by a user defined name (probably the actual table name)
/// </param>
public static void FillDataset(SqlConnection connection, CommandType commandType,
string commandText, DataSet dataSet, string[] tableNames)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().FillDataset(connection, commandType, commandText, dataSet, tableNames);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the specified SqlConnection
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// FillDataset(conn, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="dataSet">A dataset wich will contain the resultset generated by the command</param>
/// <param name="tableNames">This array will be used to create table mappings allowing the DataTables to be referenced
/// by a user defined name (probably the actual table name)
/// </param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
public static void FillDataset(SqlConnection connection, CommandType commandType,
string commandText, DataSet dataSet, string[] tableNames, params SqlParameter[] commandParameters)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().FillDataset(connection, commandType, commandText, dataSet, tableNames, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
/// using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// FillDataset(conn, "GetOrders", ds, new string[] {"orders"}, 24, 36);
/// </remarks>
/// <param name="connection">A valid SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataSet">A dataset wich will contain the resultset generated by the command</param>
/// <param name="tableNames">This array will be used to create table mappings allowing the DataTables to be referenced
/// by a user defined name (probably the actual table name)
/// </param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
public static void FillDataset(SqlConnection connection, string spName,
DataSet dataSet, string[] tableNames, params object[] parameterValues)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().FillDataset(connection, spName, dataSet, tableNames, parameterValues);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.
/// </summary>
/// <remarks>
/// e.g.:
/// FillDataset(trans, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="dataSet">A dataset wich will contain the resultset generated by the command</param>
/// <param name="tableNames">This array will be used to create table mappings allowing the DataTables to be referenced
/// by a user defined name (probably the actual table name)
/// </param>
public static void FillDataset(SqlTransaction transaction, CommandType commandType,
string commandText, DataSet dataSet, string[] tableNames)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().FillDataset(transaction, commandType, commandText, dataSet, tableNames);
}
/// <summary>
/// Execute a SqlCommand (that returns a resultset) against the specified SqlTransaction
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// FillDataset(trans, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="dataSet">A dataset wich will contain the resultset generated by the command</param>
/// <param name="tableNames">This array will be used to create table mappings allowing the DataTables to be referenced
/// by a user defined name (probably the actual table name)
/// </param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
public static void FillDataset(SqlTransaction transaction, CommandType commandType,
string commandText, DataSet dataSet, string[] tableNames, params SqlParameter[] commandParameters)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().FillDataset(transaction, commandType, commandText, dataSet, tableNames, commandParameters);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified
/// SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <remarks>
/// This method provides no access to output parameters or the stored procedure's return value parameter.
///
/// e.g.:
/// FillDataset(trans, "GetOrders", ds, new string[]{"orders"}, 24, 36);
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataSet">A dataset wich will contain the resultset generated by the command</param>
/// <param name="tableNames">This array will be used to create table mappings allowing the DataTables to be referenced
/// by a user defined name (probably the actual table name)
/// </param>
/// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
public static void FillDataset(SqlTransaction transaction, string spName,
DataSet dataSet, string[] tableNames, params object[] parameterValues)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().FillDataset(transaction, spName, dataSet, tableNames, parameterValues);
}
#endregion
#region UpdateDataset
/// <summary>
/// Executes the respective command for each inserted, updated, or deleted row in the DataSet.
/// </summary>
/// <remarks>
/// e.g.:
/// UpdateDataset(conn, insertCommand, deleteCommand, updateCommand, dataSet, "Order");
/// </remarks>
/// <param name="insertCommand">A valid transact-SQL statement or stored procedure to insert new records into the data source</param>
/// <param name="deleteCommand">A valid transact-SQL statement or stored procedure to delete records from the data source</param>
/// <param name="updateCommand">A valid transact-SQL statement or stored procedure used to update records in the data source</param>
/// <param name="dataSet">The DataSet used to update the data source</param>
/// <param name="tableName">The DataTable used to update the data source.</param>
public static void UpdateDataset(SqlCommand insertCommand, SqlCommand deleteCommand, SqlCommand updateCommand, DataSet dataSet, string tableName)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().UpdateDataset(insertCommand, deleteCommand, updateCommand, dataSet, tableName);
}
/// <summary>
/// Executes the System.Data.SqlClient.SqlCommand for each inserted, updated, or deleted row in the DataSet also implementing RowUpdating and RowUpdated Event Handlers
/// </summary>
/// <remarks>
/// e.g.:
/// SqlRowUpdatingEventHandler rowUpdating = new SqlRowUpdatingEventHandler( OnRowUpdating );
/// SqlRowUpdatedEventHandler rowUpdated = new SqlRowUpdatedEventHandler( OnRowUpdated );
/// adoHelper.UpdateDataSet(sqlInsertCommand, sqlDeleteCommand, sqlUpdateCommand, dataSet, "Order", rowUpdating, rowUpdated);
/// </remarks>
/// <param name="insertCommand">A valid transact-SQL statement or stored procedure to insert new records into the data source</param>
/// <param name="deleteCommand">A valid transact-SQL statement or stored procedure to delete records from the data source</param>
/// <param name="updateCommand">A valid transact-SQL statement or stored procedure used to update records in the data source</param>
/// <param name="dataSet">The DataSet used to update the data source</param>
/// <param name="tableName">The DataTable used to update the data source.</param>
/// <param name="rowUpdating">The AdoHelper.RowUpdatingEventHandler or null</param>
/// <param name="rowUpdated">The AdoHelper.RowUpdatedEventHandler or null</param>
public static void UpdateDataset(IDbCommand insertCommand, IDbCommand deleteCommand, IDbCommand updateCommand,
DataSet dataSet, string tableName, AdoHelper.RowUpdatingHandler rowUpdating, AdoHelper.RowUpdatedHandler rowUpdated)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().UpdateDataset(insertCommand, deleteCommand, updateCommand, dataSet, tableName, rowUpdating, rowUpdated);
}
#endregion
#region CreateCommand
/// <summary>
/// Simplify the creation of a Sql command object by allowing
/// a stored procedure and optional parameters to be provided
/// </summary>
/// <remarks>
/// e.g.:
/// SqlCommand command = CreateCommand(connenctionString, "AddCustomer", "CustomerID", "CustomerName");
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="sourceColumns">An array of string to be assigned as the source columns of the stored procedure parameters</param>
/// <returns>A valid SqlCommand object</returns>
public static SqlCommand CreateCommand(string connectionString, string spName, params string[] sourceColumns)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().CreateCommand(connectionString, spName, sourceColumns) as SqlCommand;
}
/// <summary>
/// Simplify the creation of a Sql command object by allowing
/// a stored procedure and optional parameters to be provided
/// </summary>
/// <remarks>
/// e.g.:
/// SqlCommand command = CreateCommand(conn, "AddCustomer", "CustomerID", "CustomerName");
/// </remarks>
/// <param name="connection">A valid SqlConnection object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="sourceColumns">An array of string to be assigned as the source columns of the stored procedure parameters</param>
/// <returns>A valid SqlCommand object</returns>
public static SqlCommand CreateCommand(SqlConnection connection, string spName, params string[] sourceColumns)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().CreateCommand(connection, spName, sourceColumns) as SqlCommand;
}
/// <summary>
/// Simplify the creation of a Sql command object by allowing
/// a stored procedure and optional parameters to be provided
/// </summary>
/// <remarks>
/// e.g.:
/// SqlCommand command = CreateCommand(connenctionString, "AddCustomer", "CustomerID", "CustomerName");
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandText">A valid SQL string to execute</param>
/// <param name="commandType">The CommandType to execute (i.e. StoredProcedure, Text)</param>
/// <param name="commandParameters">The SqlParameters to pass to the command</param>
/// <returns>A valid SqlCommand object</returns>
public static SqlCommand CreateCommand(string connectionString, string commandText, CommandType commandType, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().CreateCommand(connectionString, commandText, commandType, commandParameters) as SqlCommand;
}
/// <summary>
/// Simplify the creation of a Sql command object by allowing
/// a stored procedure and optional parameters to be provided
/// </summary>
/// <remarks>
/// e.g.:
/// SqlCommand command = CreateCommand(conn, "AddCustomer", "CustomerID", "CustomerName");
/// </remarks>
/// <param name="connection">A valid SqlConnection object</param>
/// <param name="commandText">A valid SQL string to execute</param>
/// <param name="commandType">The CommandType to execute (i.e. StoredProcedure, Text)</param>
/// <param name="commandParameters">The SqlParameters to pass to the command</param>
/// <returns>A valid SqlCommand object</returns>
public static SqlCommand CreateCommand(SqlConnection connection, string commandText, CommandType commandType, params SqlParameter[] commandParameters)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().CreateCommand(connection, commandText, commandType, commandParameters) as SqlCommand;
}
#endregion
#region ExecuteNonQueryTypedParams
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns no resultset) against the database specified in
/// the connection string using the dataRow column values as the stored procedure's parameters values.
/// This method will assign the parameter values based on row values.
/// </summary>
/// <param name="command">The SqlCommand to execute</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQueryTypedParams(SqlCommand command, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQueryTypedParams(command, dataRow);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns no resultset) against the database specified in
/// the connection string using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
/// </summary>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQueryTypedParams(String connectionString, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQueryTypedParams(connectionString, spName, dataRow);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified SqlConnection
/// using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
/// </summary>
/// <param name="connection">A valid SqlConnection object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQueryTypedParams(SqlConnection connection, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQueryTypedParams(connection, spName, dataRow);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified
/// SqlTransaction using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
/// </summary>
/// <param name="transaction">A valid SqlTransaction object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>An int representing the number of rows affected by the command</returns>
public static int ExecuteNonQueryTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteNonQueryTypedParams(transaction, spName, dataRow);
}
#endregion
#region ExecuteDatasetTypedParams
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in
/// the connection string using the dataRow column values as the stored procedure's parameters values.
/// This method will assign the parameter values based on row values.
/// </summary>
/// <param name="command">The SqlCommand to execute</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDatasetTypedParams(SqlCommand command, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDatasetTypedParams(command, dataRow);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in
/// the connection string using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
/// </summary>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDatasetTypedParams(string connectionString, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDatasetTypedParams(connectionString, spName, dataRow);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
/// using the dataRow column values as the store procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
/// </summary>
/// <param name="connection">A valid SqlConnection object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDatasetTypedParams(SqlConnection connection, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDatasetTypedParams(connection, spName, dataRow);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlTransaction
/// using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
/// </summary>
/// <param name="transaction">A valid SqlTransaction object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>A dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDatasetTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteDatasetTypedParams(transaction, spName, dataRow);
}
#endregion
#region ExecuteReaderTypedParams
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in
/// the connection string using the dataRow column values as the stored procedure's parameters values.
/// This method will assign the parameter values based on parameter order.
/// </summary>
/// <param name="command">The SqlCommand toe execute</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReaderTypedParams(SqlCommand command, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReaderTypedParams(command, dataRow) as SqlDataReader;
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in
/// the connection string using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReaderTypedParams(String connectionString, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReaderTypedParams(connectionString, spName, dataRow) as SqlDataReader;
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
/// using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <param name="connection">A valid SqlConnection object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReaderTypedParams(SqlConnection connection, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReaderTypedParams(connection, spName, dataRow) as SqlDataReader;
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlTransaction
/// using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <param name="transaction">A valid SqlTransaction object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>A SqlDataReader containing the resultset generated by the command</returns>
public static SqlDataReader ExecuteReaderTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteReaderTypedParams(transaction, spName, dataRow) as SqlDataReader;
}
#endregion
#region ExecuteScalarTypedParams
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the database specified in
/// the connection string using the dataRow column values as the stored procedure's parameters values.
/// This method will assign the parameter values based on parameter order.
/// </summary>
/// <param name="command">The SqlCommand to execute</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalarTypedParams(SqlCommand command, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalarTypedParams(command, dataRow);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the database specified in
/// the connection string using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalarTypedParams(String connectionString, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalarTypedParams(connectionString, spName, dataRow);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlConnection
/// using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <param name="connection">A valid SqlConnection object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalarTypedParams(SqlConnection connection, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalarTypedParams(connection, spName, dataRow);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlTransaction
/// using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <param name="transaction">A valid SqlTransaction object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalarTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteScalarTypedParams(transaction, spName, dataRow);
}
#endregion
#region ExecuteXmlReaderTypedParams
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
/// using the dataRow column values as the stored procedure's parameters values.
/// This method will assign the parameter values based on parameter order.
/// </summary>
/// <param name="command">The SqlCommand to execute</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>An XmlReader containing the resultset generated by the command</returns>
public static XmlReader ExecuteXmlReaderTypedParams(SqlCommand command, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteXmlReaderTypedParams(command, dataRow);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
/// using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <param name="connection">A valid SqlConnection object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>An XmlReader containing the resultset generated by the command</returns>
public static XmlReader ExecuteXmlReaderTypedParams(SqlConnection connection, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteXmlReaderTypedParams(connection, spName, dataRow);
}
/// <summary>
/// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlTransaction
/// using the dataRow column values as the stored procedure's parameters values.
/// This method will query the database to discover the parameters for the
/// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
/// </summary>
/// <param name="transaction">A valid SqlTransaction object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
/// <returns>An XmlReader containing the resultset generated by the command</returns>
public static XmlReader ExecuteXmlReaderTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
{
return new GotDotNet.ApplicationBlocks.Data.SqlServer().ExecuteXmlReaderTypedParams(transaction, spName, dataRow);
}
#endregion
}
/// <summary>
/// SqlHelperParameterCache provides functions to leverage a static cache of procedure parameters, and the
/// ability to discover parameters for stored procedures at run-time.
/// </summary>
public sealed class SqlHelperParameterCache
{
#region private constructor
//Since this class provides only static methods, make the default constructor private to prevent
//instances from being created with "new SqlHelperParameterCache()"
private SqlHelperParameterCache() { }
#endregion constructor
#region caching functions
/// <summary>
/// Add parameter array to the cache
/// </summary>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters to be cached</param>
public static void CacheParameterSet(string connectionString, string commandText, params SqlParameter[] commandParameters)
{
new GotDotNet.ApplicationBlocks.Data.SqlServer().CacheParameterSet(connectionString, commandText, commandParameters);
}
/// <summary>
/// Retrieve a parameter array from the cache
/// </summary>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <returns>An array of SqlParamters</returns>
public static SqlParameter[] GetCachedParameterSet(string connectionString, string commandText)
{
ArrayList tempValue = new ArrayList();
IDataParameter[] sqlP = new GotDotNet.ApplicationBlocks.Data.SqlServer().GetCachedParameterSet(connectionString, commandText);
foreach (IDataParameter parameter in sqlP)
{
tempValue.Add(parameter);
}
return (SqlParameter[])tempValue.ToArray(typeof(SqlParameter));
}
#endregion caching functions
#region Parameter Discovery Functions
/// <summary>
/// Retrieves the set of SqlParameters appropriate for the stored procedure
/// </summary>
/// <remarks>
/// This method will query the database for this information, and then store it in a cache for future requests.
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <returns>An array of SqlParameters</returns>
public static SqlParameter[] GetSpParameterSet(string connectionString, string spName)
{
ArrayList tempValue = new ArrayList();
foreach (IDataParameter parameter in new GotDotNet.ApplicationBlocks.Data.SqlServer().GetSpParameterSet(connectionString, spName))
{
tempValue.Add(parameter);
}
return (SqlParameter[])tempValue.ToArray(typeof(SqlParameter));
}
/// <summary>
/// Retrieves the set of SqlParameters appropriate for the stored procedure
/// </summary>
/// <remarks>
/// This method will query the database for this information, and then store it in a cache for future requests.
/// </remarks>
/// <param name="connectionString">A valid connection string for a SqlConnection</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="includeReturnValueParameter">A bool value indicating whether the return value parameter should be included in the results</param>
/// <returns>An array of SqlParameters</returns>
public static SqlParameter[] GetSpParameterSet(string connectionString, string spName, bool includeReturnValueParameter)
{
ArrayList tempValue = new ArrayList();
foreach (IDataParameter parameter in new GotDotNet.ApplicationBlocks.Data.SqlServer().GetSpParameterSet(connectionString, spName, includeReturnValueParameter))
{
tempValue.Add(parameter);
}
return (SqlParameter[])tempValue.ToArray(typeof(SqlParameter));
}
/// <summary>
/// Retrieves the set of SqlParameters appropriate for the stored procedure
/// </summary>
/// <remarks>
/// This method will query the database for this information, and then store it in a cache for future requests.
/// </remarks>
/// <param name="connection">A valid SqlConnection object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <returns>An array of SqlParameters</returns>
/// <exception cref="System.ArgumentNullException">Thrown if spName is null</exception>
/// <exception cref="System.ArgumentNullException">Thrown if connection is null</exception>
public static SqlParameter[] GetSpParameterSet(IDbConnection connection, string spName)
{
return GetSpParameterSet(connection, spName, false);
}
/// <summary>
/// Retrieves the set of SqlParameters appropriate for the stored procedure
/// </summary>
/// <remarks>
/// This method will query the database for this information, and then store it in a cache for future requests.
/// </remarks>
/// <param name="connection">A valid SqlConnection object</param>
/// <param name="spName">The name of the stored procedure</param>
/// <param name="includeReturnValueParameter">A bool value indicating whether the return value parameter should be included in the results</param>
/// <returns>An array of SqlParameters</returns>
/// <exception cref="System.ArgumentNullException">Thrown if spName is null</exception>
/// <exception cref="System.ArgumentNullException">Thrown if connection is null</exception>
public static SqlParameter[] GetSpParameterSet(IDbConnection connection, string spName, bool includeReturnValueParameter)
{
ArrayList tempValue = new ArrayList();
foreach (IDataParameter parameter in new GotDotNet.ApplicationBlocks.Data.SqlServer().GetSpParameterSet(connection, spName, includeReturnValueParameter))
{
tempValue.Add(parameter);
}
return (SqlParameter[])tempValue.ToArray(typeof(SqlParameter));
}
#endregion Parameter Discovery Functions
}
}