本文整理汇总了C#中SQLHelper类的典型用法代码示例。如果您正苦于以下问题:C# SQLHelper类的具体用法?C# SQLHelper怎么用?C# SQLHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLHelper类属于命名空间,在下文中一共展示了SQLHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateDatabase
/// <summary>
/// Creates a database out of the structure it is given
/// </summary>
/// <param name="Database">Database structure</param>
/// <param name="ConnectionString">The connection string to the database's location</param>
public static void CreateDatabase(Database Database,string ConnectionString)
{
try
{
string Command = BuildCommands(Database);
string[] Splitter = { "\n" };
string[] Commands = Command.Split(Splitter, StringSplitOptions.RemoveEmptyEntries);
string DatabaseConnectionString = Regex.Replace(ConnectionString, "Initial Catalog=(.*?;)", "");
using (SQLHelper Helper = new SQLHelper(Commands[0], DatabaseConnectionString, CommandType.Text))
{
try
{
Helper.Open();
Helper.ExecuteNonQuery();
}
catch { throw; }
finally { Helper.Close(); }
}
for (int x = 1; x < Commands.Length; ++x)
{
using (SQLHelper Helper = new SQLHelper(Commands[x], ConnectionString, CommandType.Text))
{
try
{
Helper.Open();
Helper.ExecuteNonQuery();
}
catch { throw; }
finally { Helper.Close(); }
}
}
}
catch { throw; }
}
开发者ID:pengyancai,项目名称:cs-util,代码行数:39,代码来源:SQLServer.cs
示例2: getNewsDt
public DataTable getNewsDt()
{
SQLHelper db = new SQLHelper();
try
{
string pagesize = Pager1.PageSize.ToString();
string curpage = pg.request(Pager1.PagePara);
string pageCount = "";//总页数
int rowCount = 0;
if (pagesize == "") pagesize = "10";
if (curpage == "") curpage = "1";
string sql = "SELECT id,name,OrderId,JianCheng FROM " + com.tablePrefix + "province WHERE 1=1 ";
sql += " ORDER BY OrderId";
sql = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
db.sql = sql;
DataSet ds = db.Get_DataSet();
DataTable dt = ds.Tables[2];
pageCount = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
rowCount = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
Pager1.RecordCount = rowCount;
//if (rowCount == 0) Pager1.Visible = false;
return dt;
}
catch (NullReferenceException ex)
{
Response.Write("2. " + ex.Message + "。");
//Response.End();
return new DataTable();
}
}
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:31,代码来源:ProvinceManage.aspx.cs
示例3: del
public static void del(string id)
{
SQLHelper.DeleteEntity<DXLb>(id);
SQLHelper db = new SQLHelper();
db.sql = "UPDATE lb SET isDeleted=1 WHERE id="+id;
db.ExecSql();
}
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:7,代码来源:clsLB.cs
示例4: getNewsDt
public DataTable getNewsDt()
{
productid = hlbid.Value;
SQLHelper db = new SQLHelper();
string pagesize = Pager0.PageSize.ToString();
string curpage = pg.request(Pager0.PagePara);
string pageCount = "";//总页数
int rowCount = 0;
if (pagesize == "") pagesize = "20";
if (curpage == "") curpage = "1";
string sql = @"SELECT c.imgTypeName,b.ColorValue,b.ColorName
,SUBSTRING((''000''+CONVERT(varchar,b.OrderId)),LEN(''000''+CONVERT(varchar,b.OrderId))-2,3)+''-''+b.ColorName AS ColorText
,a.*
FROM "[email protected]"News a LEFT JOIN "[email protected]"Color b ON a.colorId=b.id
LEFT JOIN "[email protected]"ProductImgType c ON c.id =a.pro_imgTypeid
WHERE a.ParentNewsID=" + productid;
sql += " ORDER BY a.OrderId";
sql = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
db.sql = sql;
DataSet ds = db.Get_DataSet();
DataTable dt = ds.Tables[2];
pageCount = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
rowCount = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
Pager0.RecordCount = rowCount;
if (rowCount == 0) Pager0.Visible = false;
return dt;
}
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:27,代码来源:ProPicManage.aspx.cs
示例5: btnRun_Click
protected void btnRun_Click(object sender, EventArgs e)
{
string sql = tbxSql.Text.Trim().ToUpper();
SQLHelper db = new SQLHelper();
db.sql = sql;
if (sql.Contains("SELECT "))
{
DataTable dt = db.Get_DataTable();
gv.DataSource = dt;
gv.DataBind();
lblMsg.Text = "执行完成,查询结果如下:";
}
else
{
string result = db.ExecSql();
if (result == "1")
{
lblMsg.Text = "执行完成";
}
else
{
lblMsg.Text = "执行失败," + result;
}
}
}
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:25,代码来源:execSql.aspx.cs
示例6: bindGv
public void bindGv(bool addNewRow)
{
lbid = hlbid.Value;
SQLHelper db = new SQLHelper();
string pagesize = Pager2.PageSize.ToString();
string curpage = pg.request(Pager2.PagePara);
string pageCount = "";//总页数
int rowCount = 0;
if (pagesize == "") pagesize = "5";
if (curpage == "") curpage = "1";
string sql = @"SELECT *
FROM "[email protected]"News
WHERE lbid=" + lbid;
sql += " ORDER BY isTop DESC,IsIndex DESC,EditTime DESC";
sql = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
db.sql = sql;
DataSet ds = db.Get_DataSet();
DataTable dt = ds.Tables[2];
pageCount = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
rowCount = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
Pager2.RecordCount = rowCount;
if (rowCount == 0) Pager2.Visible = false;
if (addNewRow)
{
DataRow newRow = dt.NewRow();
dt.Rows.Add(newRow);
}
GV.DataSource = dt.DefaultView;
GV.DataBind();
}
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:30,代码来源:VideoManage.aspx.cs
示例7: CreateDatabase
/// <summary>
/// Creates a database out of the structure it is given
/// </summary>
/// <param name="Database">Database structure</param>
/// <param name="ConnectionString">The connection string to the database's location</param>
public static void CreateDatabase(Database Database, string ConnectionString)
{
string Command = BuildCommands(Database);
string[] Splitter = { "\n" };
string[] Commands = Command.Split(Splitter, StringSplitOptions.RemoveEmptyEntries);
ConnectionString = Regex.Replace(ConnectionString, "Pooling=(.*?;)", "", RegexOptions.IgnoreCase) + ";Pooling=false;";
string DatabaseConnectionString = Regex.Replace(ConnectionString, "Initial Catalog=(.*?;)", "", RegexOptions.IgnoreCase);
using (SQLHelper Helper = new SQLHelper(Commands[0], DatabaseConnectionString, CommandType.Text))
{
Helper.ExecuteNonQuery();
}
using (SQLHelper Helper = new SQLHelper("", ConnectionString, CommandType.Text))
{
try
{
Helper.BeginTransaction();
for (int x = 1; x < Commands.Length; ++x)
{
Helper.Command = Commands[x];
Helper.ExecuteNonQuery();
}
Helper.Commit();
}
catch { Helper.Rollback(); throw; }
}
}
开发者ID:yiwayhb,项目名称:Craig-s-Utility-Library,代码行数:31,代码来源:SQLServer.cs
示例8: PeptideDAL
public PeptideDAL(string sDataBase)
{
string sServer = "10.60.43.39";
string sUid = "root";
string sPwd = "root";
string sMySqlConnString = string.Format("Server={0};Database={1};Uid={2};Pwd={3};Persist Security Info=True;Pooling=False;", sServer, sDataBase, sUid, sPwd);
sqlHelper = new SQLHelper(sMySqlConnString);
lstColName.Add("ID");
lstColName.Add("AC");
lstColName.Add("DT");
lstColName.Add("DE");
lstColName.Add("GN");
lstColName.Add("OS");
lstColName.Add("OC");
lstColName.Add("OX");
lstColName.Add("RN");
lstColName.Add("RP");
lstColName.Add("RX");
lstColName.Add("RA");
lstColName.Add("RT");
lstColName.Add("RL");
lstColName.Add("RC");
lstColName.Add("RG");
lstColName.Add("CC");
lstColName.Add("DR");
lstColName.Add("PE");
lstColName.Add("KW");
lstColName.Add("FT");
lstColName.Add("SQ");
lstColName.Add("ModResSingle");
}
开发者ID:jingpeng,项目名称:protein-goggle-search-core,代码行数:32,代码来源:PeptideDAL.cs
示例9: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
string folderLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "jobTracker");
string dbLocation = Path.Combine(folderLocation,"jobTrackerDB.sqlite");
sqlHelper = new SQLHelper(dbLocation);
if (!File.Exists(dbLocation))
{
sqlHelper.createDB();
sqlHelper.createTable("jobs", createJobsTable.getJobsbasicInfo());
}
dataLocation = dbLocation;
txtExportLocation.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var jobsColumns = sqlHelper.getColumnNames("jobs");
foreach (string s in jobsColumns)
{
listViewDisplay.Columns.Add(s);
}
updateList();
}
开发者ID:GabrielSamp,项目名称:.Net-Programs,代码行数:31,代码来源:JobTrackerMain.cs
示例10: getNewsDt
public DataTable getNewsDt()
{
SQLHelper db = new SQLHelper();
try
{
string pagesize = Pager1.PageSize.ToString();
string curpage = pg.request(Pager1.PagePara);
string pageCount = "";//总页数
int rowCount = 0;
if (pagesize == "") pagesize = "15";
if (curpage == "") curpage = "1";
string sql = @"SELECT id,ColorName,ColorValue,SUBSTRING((''000''+CONVERT(varchar,OrderId)),LEN(''000''+CONVERT(varchar,OrderId))-3,4) AS OrderId FROM " + com.tablePrefix + "Color ORDER BY OrderId";
sql = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
db.sql = sql;
DataSet ds = db.Get_DataSet();
DataTable dt = ds.Tables[2];
pageCount = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
rowCount = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
Pager1.RecordCount = rowCount;
if (rowCount == 0) Pager1.Visible = false;
return dt;
}
catch (Exception ex)
{
Response.Write("2. " + ex.Message + "。");
//Response.End();
return null;
}
}
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:29,代码来源:ColorManage.aspx.cs
示例11: AdminInfo
public static DataTable AdminInfo(int id)
{
string sql = "SELECT * FROM " + com.tablePrefix + "Admin WHERE id=" + id.ToString() + "";
SQLHelper db = new SQLHelper();
db.sql = sql;
return db.Get_DataTable();
}
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:7,代码来源:clsAdmin.cs
示例12: GetMaxItemID
/// <summary>
/// 得到當前最大ToDo Item ID
/// </summary>
/// <returns></returns>
private string GetMaxItemID(SQLHelper conn, string user_id, out int mySeq)
{
string rtn = "";
mySeq = 0;
string matchString = GetMatchString("D");
DataTable table = conn.OpenDataTable("select isnull(max(td_no),'') as maxid from lrtd00h (nolock) where td_no like '" + matchString + "%'", CommandType.Text);
if (table.Rows.Count > 0)
{
rtn = table.Rows[0][0].ToString();
}
table = conn.OpenDataTable("select isnull(max(td_seq),0) as maxid from lrtd00h (nolock) where td_owner= '" + user_id + "'", CommandType.Text);
if (table.Rows.Count > 0)
{
mySeq = Convert.ToInt32(table.Rows[0][0]);
}
else
{
mySeq = 0;
}
// 只留下流水號
rtn = rtn.Replace(matchString, "");
if (rtn == "")
rtn = "00000";
return rtn;
}
开发者ID:Donnie888,项目名称:LxServer,代码行数:34,代码来源:ToDoManagerService.cs
示例13: bindFunctionList
protected void bindFunctionList()
{
functionList.Items.Clear();
//for (int i = 1; i <= 35; i++)
//{
// ListItem li = new ListItem();
// string img = "0" + i.ToString() + ".jpg";
// int len = img.Length;
// img = img.Substring(len - 6, 6);
// li.Value = img;
// li.Text = "<img src='../images/function_icon/" + img + "' />";
// functionList.Items.Add(li);
//}
SQLHelper db = new SQLHelper();
db.sql = "SELECT NewsId,Title,Description,pic FROM " + com.tablePrefix + "News WHERE lbid=64";
DataTable dt = db.Get_DataTable();
functionList.DataSource = dt;
foreach (DataRow dr in dt.Rows)
{
ListItem li = new ListItem();
li.Value = dr["NewsId"].ToString();
li.Text = "<img src='" + dr["pic"].ToString() + "' title='" + dr["Description"].ToString() + "' />";
functionList.Items.Add(li);
}
}
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:26,代码来源:ProAdd.aspx.cs
示例14: bindProPlb
protected void bindProPlb()
{
SQLHelper db = new SQLHelper();
db.sql = "SELECT lbid,lbname FROM " + com.tablePrefix + "lb WHERE parentid=4 Order By OrderId";
DataTable dt = db.Get_DataTable();
rptProLbParent.DataSource = dt;
rptProLbParent.DataBind();
}
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:8,代码来源:LeftMenu.aspx.cs
示例15: AddLb
/// <summary>
/// 添加栏目
/// </summary>
/// <param name="lbname">栏目名称</param>
/// <param name="parentid">父栏目ID</param>
/// <returns>int,1=成功,0=已存在</returns>
public static string AddLb(string lbname, string parentid)
{
string maxlbid = MaxLbid();
string sql = "INSERT INTO " + com.tablePrefix + "lb (lbid,lbname,parentid,OrderId) VALUES(" + maxlbid + ",'" + lbname + "'," + parentid + "," + maxlbid + ")";
SQLHelper db = new SQLHelper();
db.sql = sql;
return db.ExecSql();
}
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:14,代码来源:clsLB.cs
示例16: PeptideModResDAL
public PeptideModResDAL(string sDataBase)
{
string sServer = "10.60.43.39";
string sUid = "root";
string sPwd = "root";
string sMySqlConnString = string.Format("Server={0};Database={1};Uid={2};Pwd={3};Persist Security Info=True;Pooling=False;", sServer, sDataBase, sUid, sPwd);
sqlHelper = new SQLHelper(sMySqlConnString);
}
开发者ID:jingpeng,项目名称:protein-goggle-search-core,代码行数:8,代码来源:PeptideModResDAL.cs
示例17: OrderSystemData
/// <summary>
/// DNFData库的数据库连接对象
/// </summary>
/// <returns></returns>
public static Safe.Base.Contract.IDbHelper OrderSystemData()
{
//return Safe.CFData.DbHelper.Factory.GetIDbHelper(EConnType.MSSQL_CFDATA, true);
string connString = "data source=127.0.0.1;initial catalog=CYJH_OrderSystem;user id=sa;password=123456a;persist security info=True;Connection Timeout=5000;";//ConfigurationManager.ConnectionStrings["CYJHOrderSysConn"].ConnectionString;
SQLHelper sqlHelp = new SQLHelper(connString, true);
return sqlHelp;
//Safe.Base.DbHelper.SQLHelper.FromFile(@"D:\Configs\DataBase\CYJH_OrderSystem.dbc", true);
}
开发者ID:DennisYe,项目名称:DianCanSystem,代码行数:12,代码来源:SQLHelps.cs
示例18: btnAdd_Click
protected void btnAdd_Click(object sender, EventArgs e)
{
string lbid = hLbid.Value;
string id = hID.Value;
string title = pg.GetSafeString(txtTitle.Text);
string cityid = ddlCity.SelectedValue;
string newsBody = tbxBody.Text;
string tel = tbxDesc.Text;
//if (tel.Length < 8)
//{
// alert.ShowAndBack(Page, "联系方式不能小于8位数字");
// return;
//}
string sql = "";
if (cityid == "0" || cityid.Length==0)
{
alert.ShowAndBack(Page, "请选择省市");
return;
}
if (id.Length > 0)
{
//修改
sql = "UPDATE News SET Title='" + title + "',cityid='" + cityid + "',Description='" + tel + "',NewsBody='" + newsBody + "',EditTime=getdate() WHERE NewsID=" + id;
SQLHelper db = new SQLHelper();
db.sql = sql;
if (db.ExecSql() == "1")
{
alert.showAndGo("修改成功", "NetworkManage.aspx");
}
else
{
//alert.ShowAndBack(Page, "修改失败");
Response.Write(sql);
Response.End();
}
}
else
{
//添加
string newsid = clsNews.MaxNewsid();
lbid = "24";
sql = "INSERT INTO News(NewsID,lbid,Title,cityid,Description,NewsBody,Creator) VALUES(" + newsid + "," + lbid + ",'" + title + "','" + cityid + "','" + tel + "','" + newsBody + "','" + Session["AdminName"].ToString() + "')";
SQLHelper db = new SQLHelper();
db.sql = sql;
string result = db.ExecSql();
if (result == "1")
{
alert.showAndGo("添加成功", "NetworkManage.aspx");
}
else
{
Response.Write(result+",sql="+sql);
Response.End();
//alert.ShowAndBack(Page, "添加失败" + result);
}
}
}
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:58,代码来源:NetworkAdd.aspx.cs
示例19: GetSIMREG_NEWFORMs
public BESIMREG_NEWFORMs GetSIMREG_NEWFORMs(string msisdnTitle, string requestById, string requestTypeId, string deliverById, string requestFromDate, string requestToDate, string deliverFromDate, string deliverToDate, SQLHelper sqlHelper)
{
string sql = string.Empty;
string whereSql = string.Empty;
BESIMREG_NEWFORMs SIMREG_NEWFORMs = new BESIMREG_NEWFORMs();
try
{
whereSql += sqlHelper.MakeSQL(sql + " MSISDNTITLE=nvl($s,MSISDNTITLE)", msisdnTitle);
if (Convert.ToInt32(requestById) > 0)
{
whereSql += sqlHelper.MakeSQL(sql + " AND REQUESTEDBYID=$n", requestById);
}
if (Convert.ToInt32(requestTypeId) > 0)
{
whereSql += sqlHelper.MakeSQL(sql + " AND REQUESTEDTYPEID=$n", requestTypeId);
}
if (Convert.ToInt32(deliverById) > 0)
{
whereSql += sqlHelper.MakeSQL(sql + " AND DELIVEREDBYID=$n", deliverById);
}
if (!String.IsNullOrEmpty(requestFromDate))
{
whereSql += sqlHelper.MakeSQL(sql + " AND REQUESTEDDATE>=$s", requestFromDate);
}
if (!String.IsNullOrEmpty(requestToDate))
{
whereSql += sqlHelper.MakeSQL(sql + " AND REQUESTEDDATE<=$s", requestToDate);
}
if (!String.IsNullOrEmpty(deliverFromDate))
{
whereSql += sqlHelper.MakeSQL(sql + " AND DELIVEREDBYDATE>=$s", deliverFromDate);
}
if (!String.IsNullOrEmpty(deliverToDate))
{
whereSql += sqlHelper.MakeSQL(sql + " AND DELIVEREDBYDATE<=$s", deliverToDate);
}
sql = sqlHelper.MakeSQL(@"SELECT * FROM SIMREG_NEWFORM WHERE $q ORDER BY ID", whereSql);
IDataReader reader = sqlHelper.ExecuteQuery(sql);
AddToSIMREG_NEWFORMCollection(SIMREG_NEWFORMs, reader);
reader.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return SIMREG_NEWFORMs;
}
开发者ID:raselahmmedgit,项目名称:simreg-sample,代码行数:57,代码来源:DASIMREG_NEWFORM.cs
示例20: bindProvince
protected void bindProvince()
{
SQLHelper db = new SQLHelper();
db.sql = "SELECT id,name FROM " + com.tablePrefix + "Province ORDER BY OrderID";
DataTable dt = db.Get_DataTable();
ddlProvince.DataSource = dt;
ddlProvince.DataValueField = "id";
ddlProvince.DataTextField = "name";
ddlProvince.DataBind();
}
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:10,代码来源:NetworkAdd.aspx.cs
注:本文中的SQLHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论