随机查询
2015-04-05 21:45:43 访问(1293) 赞(0) 踩(0)
生成和输出的SQL语句
select
t.ID, t.TheName, t.CreateTime,
t.UpdateTime
from UTB_EXAM_CLASS t
order by newid()
关键代码
// 随机查询 //
entity.IsRandomForOrder = true;
代码写法
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SlowX.DAL.Helpers;
using SlowX.Core.ICoreClasses;
using System.Data;
using SlowX.Functions.Functions;
using SlowX.Core.CoreClasses;
public partial class ExamSQL : System.Web.UI.Page
{
protected string strResult = "";
protected void Page_Load(object sender, EventArgs e)
{
DataBindTheContorls(null);
}
#region 操作
/// <summary>
///
/// </summary>
/// <param name="xdbHelper"></param>
protected void DataBindTheContorls(DBHelper xdbHelper)
{
string theResult = null;
bool bIsCreate = true;
if (xdbHelper == null)
{
xdbHelper = SlowX.DAL.Helpers.DBHelper.CreateDBHelper();
}
else
{
// 没有打开链接 //
bIsCreate = xdbHelper.IsNotOpen();
}
try
{
if (bIsCreate)
xdbHelper.OpenDBHelper();
SlowX.ExamLib.Business.UTB_EXAM_CLASS
bll
=
SlowX.ExamLib.Business.UTB_EXAM_CLASS.instance;
SlowX.ExamLib.Entity.UTB_EXAM_CLASS
entity
=
new SlowX.ExamLib.Entity.UTB_EXAM_CLASS();
// 随机查询 //
entity.IsRandomForOrder = true;
DataSet ds = bll.List(entity, xdbHelper);
theResult =
@"<textarea name=""TextBox1"" rows=""2"" cols=""20"" id=""TextBox1"" style=""height:400px;width:99%;"">"
+ bll.BuildSqlList(entity, xdbHelper)
+ "</textarea>";
theResult += "<br /><br />";
theResult += DataSetSlowXFunctions.DataSetToHtmlTable(ds, true);
if (bIsCreate)
xdbHelper.EndDBHelper();
}
catch (Exception err)
{
if (bIsCreate)
xdbHelper.TranDBHelper();
throw err;
}
finally
{
if (bIsCreate)
xdbHelper.FinallyDBHelper();
}
strResult = theResult;
}
#endregion 操作
}
标签:
随机查询 


上一条:
下一条:
相关评论
发表评论