using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using AC;
public partial class Default2 : System.Web.UI.Page
{
cl_ShowLog clShowLog = new cl_ShowLog();
public DataSet dsets = new DataSet();
public void BinddataToGridDate()
{
clShowLog.sDate = txtsDate.Text.ToString();
clShowLog.eDate = txteDate.Text.ToString();
dsets = clShowLog.Show_By_Date();
GridView1.DataSource = dsets.Tables[0];
GridView1.DataBind();
}
protected void btOK_Click(object sender, EventArgs e)
{
if (rdDate.Checked == true)
{
BinddataToGridDate();
}
}
}
cl_ShowLog.cs Code (ASP C#.NET)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
public class cl_ShowLog
{
public string sDate
{ get; set; }
public string eDate
{ get; set; }
public DataSet Show_By_Date()
{
DataSet dset = new DataSet();
SqlConnection connDB = new SqlConnection(WebConfigurationManager.ConnectionStrings["connDB"].ConnectionString);
connDB.Open();
SqlCommand sqlcmd = new SqlCommand("SP_ACU_LOG_BY_DATE", connDB);
sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.Parameters.Add(new SqlParameter("@strSDate", sDate));
sqlcmd.Parameters.Add(new SqlParameter("@strEDate", eDate));
SqlDataReader reader = sqlcmd.ExecuteReader();
dset.Load(reader, LoadOption.PreserveChanges, "tbDate");
connDB.Close();
return dset;
}
}
ALTER proc [dbo].[SP_ACU_LOG_BY_DATE]
@strSDate nvarchar(10),
@strEDate nvarchar(10)
as
BEGIN
select pnr.Person_ID as 'รหัสเจ้าหน้าที่',pnr.FullName_TH as 'ชื่อ - สกุล',pnr.Position 'ตำแหน่ง',org.Org_Desc as 'หน่วยงาน',
g.Gate_Desc as 'ชือประตู',Convert(nvarchar(10),acl.Time,103)as 'วันที่' ,CONVERT(nvarchar(10),acl.Time,108) as 'เวลา'
From tbl_aculog acl inner join tbl_Gate g on acl.Gate_ID=g.Gate_ID
inner join tbl_PerNR pnr On acl.mifareNo = pnr.Mifare_No
inner join tbl_Organization org On pnr.Org_ID = org.Org_ID
where Convert(datetime,(Convert(nvarchar(10),acl.Time,103)),103) BETWEEN @strSDate and @strEDate
order by acl.Time asc
END
ลองแก้ใน Procedures ตรง Order แล้ว ก็ยังไม่หาย
รบกวนดูให้หน่อยนะคะ ขอบคุณล่วงหน้ามากๆๆค่ะ T_T
Tag : .NET, Ms SQL Server 2008, Web (ASP.NET), Win (Windows App), C#, VS 2010 (.NET 4.x)