本文整理汇总了C#中Database.ExecuteDataTable方法的典型用法代码示例。如果您正苦于以下问题:C# Database.ExecuteDataTable方法的具体用法?C# Database.ExecuteDataTable怎么用?C# Database.ExecuteDataTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database.ExecuteDataTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
int id;
if (!int.TryParse(Request.QueryString["id"], out id))
{
Response.Redirect("~/MediaCenter.aspx");
}
Database db = new Database();
Lang lang = new Lang();
db.AddParameter("@lang", lang.getCurrentLang());
db.AddParameter("@id", id);
DataTable dt = db.ExecuteDataTable("select top(3) * from Report where [email protected] and (not [email protected]) Order by id desc");
Repeater1.DataSource = dt;
Repeater1.DataBind();
db.AddParameter("@lang", lang.getCurrentLang());
dt = db.ExecuteDataTable("select top(3) * from SocialEvent where [email protected] Order by id desc");
Repeater2.DataSource = dt;
Repeater2.DataBind();
db.AddParameter("@lang", lang.getCurrentLang());
db.AddParameter("@id", id);
dt = db.ExecuteDataTable("select * from Report where [email protected] and [email protected]");
Repeater3.DataSource = dt;
Repeater3.DataBind();
if (dt.Rows.Count == 0)
{
Response.Redirect("~/MediaCenter.aspx");
}
}
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Database db = new Database();
db.LoadDDL("category","title",ref ddlCat,"ادخل فئة المعاملة","catid=1");
db.LoadDDL("category", "title", ref ddlSec, "ادخل سرية المعاملة", "catid=2");
db.LoadDDL("category", "title", ref ddlLegal, "ادخل الوضع القانوني", "catid=3");
DataTable dt = db.ExecuteDataTable("select * from document");
ddlRDoc1.Items.Add(new ListItem("اختر معاملة", "-1"));
ddlRDoc2.Items.Add(new ListItem("اختر معاملة", "-1"));
ddlRDoc3.Items.Add(new ListItem("اختر معاملة", "-1"));
ddlRDoc4.Items.Add(new ListItem("اختر معاملة", "-1"));
ddlRDoc5.Items.Add(new ListItem("اختر معاملة", "-1"));
foreach (DataRow row in dt.Rows)
{
ddlRDoc1.Items.Add(new ListItem(row["title"].ToString()+"-"+row["no"].ToString(),row["id"].ToString()));
ddlRDoc2.Items.Add(new ListItem(row["title"].ToString() + "-" + row["no"].ToString(), row["id"].ToString()));
ddlRDoc3.Items.Add(new ListItem(row["title"].ToString() + "-" + row["no"].ToString(), row["id"].ToString()));
ddlRDoc4.Items.Add(new ListItem(row["title"].ToString() + "-" + row["no"].ToString(), row["id"].ToString()));
ddlRDoc5.Items.Add(new ListItem(row["title"].ToString() + "-" + row["no"].ToString(), row["id"].ToString()));
}
if (Request.QueryString["Op"].Equals("Edit"))
{
LoadData();
}
}
}
示例3: LoadData
private void LoadData(string name = "", string jobTitle = "",string organization="")
{
Database db = new Database();
string sql = "select * from users where IsActive=1 ";
if (!string.IsNullOrWhiteSpace(name))
{
sql += " and users.name like '%' + @name + '%'";
db.AddParameter("@name", name);
}
if (!string.IsNullOrWhiteSpace(jobTitle))
{
sql += " and users.JobTitle like '%' + @JobTitle + '%'";
db.AddParameter("@JobTitle", jobTitle);
}
if (!string.IsNullOrWhiteSpace(organization))
{
sql += " and users.organization like '%' + @organization + '%'";
db.AddParameter("@organization", organization);
}
DataTable dt = db.ExecuteDataTable(sql);
ListView1.DataSource = dt;
ListView1.DataBind();
}
示例4: btnLogin_OnClick
protected void btnLogin_OnClick(object sender, EventArgs e)
{
string loginUrl = Request.Url.AbsoluteUri.Replace("forgetPassword.aspx", "login.aspx");
string sql = "select * from users where [email protected]";
Database db=new Database();
db.AddParameter("@username", txtUserName.Text);
DataTable dt = db.ExecuteDataTable(sql);
if(dt.Rows.Count==0)
{
ErrorDiv.Visible = true;
lblError.Text = "هذا البريد الالكتروني غير مسجل لدينا الرجاء مراجعة مدير النظام";
return;
}
StringBuilder strBuild=new StringBuilder();
strBuild.Append("<h1>المركز الوطني للبحوث و الدراسات الاجتماعية</h1>");
strBuild.Append("<h2>استرجاع كلمة السر الخاص بنظام الارشفة</h2>");
strBuild.Append("<h4>معلومات الدخول الخاص بك الى النظام</h4>");
strBuild.Append(String.Format("<p>اسم المستخدم : <b>{0}</b></p>",dt.Rows[0]["username"].ToString()));
strBuild.Append(String.Format("<p>كلمة السر : <b>{0}</b></p>",dt.Rows[0]["password"]));
strBuild.Append(String.Format("<p>لتسجيل الدخول <a href=\"{0}\">من هنا</a></p>", loginUrl));
SendMail mail=new SendMail();
mail.SendMsg(dt.Rows[0]["username"].ToString(), "استعادة كلمة المرور", strBuild.ToString());
ClientScript.RegisterClientScriptBlock(this.GetType(),"msgBox","alert('تم ارسال كلمة السر على بريدك الالكتروني');",true);
}
示例5: Page_Init
protected void Page_Init(object sender, EventArgs e)
{
if (Request.Cookies["ASCMSKeepOnline"] != null)
{
int id;
if (int.TryParse(Request.Cookies["ASCMSKeepOnline"].Value, out id))
{
Database db = new Database();
db.AddParameter("@id", id);
System.Data.DataTable dt = db.ExecuteDataTable("Select * from adminUsers where [email protected]");
db.Dispose1();
if (dt.Rows.Count != 0)
{
AdminInfo admininfo = new AdminInfo(dt.Rows[0]["id"].ToString(), dt.Rows[0]["name"].ToString(), dt.Rows[0]["username"].ToString(), dt.Rows[0]["password"].ToString(), dt.Rows[0]["email"].ToString(), dt.Rows[0]["permition"].ToString());
Session["AdminInfo"] = admininfo;
}
}
}
if (Session["AdminInfo"] == null)
{
Response.Redirect("Login.aspx?url=" + Request.RawUrl);
}
if (!Page.IsPostBack)
{
AdminInfo admininfo = (AdminInfo)Session["AdminInfo"];
HyperLink1.Text = "<span><i class=\"fa fa-smile-o\"></i> " + admininfo.Name + "!</span>";
HyperLink1.NavigateUrl = "../AdminOp.aspx?id="+admininfo.Id+"&Op=Edit";
}
}
示例6: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
int id = -1;
if (int.TryParse(Request.QueryString["id"], out id))
{
Database db = new Database();
Lang lang = new Lang();
db.AddParameter("@id", id);
db.AddParameter("@lang", lang.getCurrentLang());
DataTable dt = db.ExecuteDataTable("select country.name as countryname,researcher.* from Researcher inner join Country on Researcher.Country=Country.id where [email protected] and researcher.IsAproved=1 and [email protected]");
if(dt.Rows.Count==0)
{
Response.Redirect("Experts.aspx");
}
Repeater1.DataSource = dt;
Repeater1.DataBind();
LoadResearch(id,"",null,null);
txtTitle.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {__doPostBack('" + btnSearch.UniqueID + "','');}} ");
txtFrom.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {__doPostBack('" + btnSearch.UniqueID + "','');}} ");
txtTo.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {__doPostBack('" + btnSearch.UniqueID + "','');}} ");
}
}
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Database db=new Database();
db.AddParameter("@pageKey", "ContactUs");
DataTable dt = db.ExecuteDataTable("select * from Pages where [email protected]");
if (dt.Rows.Count > 0)
{
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
db.LoadDDL("Filetarget","title",ref ddlField,"المجال");
db.LoadDDL("FileType", "title", ref ddlType, "نوع الملف");
db.LoadDDL("country", "name", ref ddlCountry, "الدولة", "lang=2");
if (!t.IsUserLogin(Session))
{
mainContainerBody.Attributes["class"] += " extended";
}
else
{
Panel1.Visible = true;
}
}
}
示例8: btnLogin_Click
protected void btnLogin_Click(object sender, EventArgs e)
{
Database db = new Database();
db.AddParameter("@uname", txtUserName.Text);
db.AddParameter("@password", txtPassword.Text);
System.Data.DataTable dt = db.ExecuteDataTable("Select * from AdminUsers where ([email protected] or [email protected]) and ([email protected])");
if (dt.Rows.Count != 0)
{
if(cbRememberMe.Checked)
{
HttpCookie c=new HttpCookie("ASUserName", txtUserName.Text);
c.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(c);
c = new HttpCookie("ASPassword", txtPassword.Text);
c.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(c);
}
else
{
HttpCookie c = new HttpCookie("ASUserName", "");
c.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(c);
c = new HttpCookie("ASPassword", "");
c.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(c);
}
if(cbKeepMeLogin.Checked)
{
HttpCookie c = new HttpCookie("ASCMSKeepOnline", dt.Rows[0]["id"].ToString());
c.Expires = DateTime.Now.AddDays(20);
Response.Cookies.Add(c);
}
else
{
HttpCookie c = new HttpCookie("ASCMSKeepOnline", "");
c.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(c);
}
AdminInfo admininfo = new AdminInfo(dt.Rows[0]["id"].ToString(), dt.Rows[0]["name"].ToString(), dt.Rows[0]["username"].ToString(), dt.Rows[0]["password"].ToString(), dt.Rows[0]["email"].ToString(), dt.Rows[0]["permition"].ToString());
Session["AdminInfo"] = admininfo;
if (Request.QueryString["url"] == null)
{
Response.Redirect("default.aspx");
}
else
{
Response.Redirect(Request.QueryString["url"]);
}
}
else
{
ErrorDiv.Visible = true;
sp1.Visible = true;
lblError.Text = "<i class=\"fa fa-exclamation-triangle fcRed\"></i> خطا في بيانات الدخول الرجاء التاكد من اسم المستخدم و كلمة المرور ";
}
}
示例9: btnForgetPass_Click
protected void btnForgetPass_Click(object sender, EventArgs e)
{
AppFunctions v = new AppFunctions();
if (!v.IsEmailValid(txtEmail.Text))
{
ErrorDiv.Visible = true;
sp1.Visible = true;
lblError.Text = "<i class=\"fa fa-exclamation-triangle fcRed\"></i> الرجاء التأكد من البريد الالكتروني.";
return;
}
Database db = new Database();
db.AddParameter("@email", txtEmail.Text);
System.Data.DataTable dt = db.ExecuteDataTable("Select * from AdminUsers where [email protected]");
if (dt.Rows.Count == 0)
{
ErrorDiv.Visible = true;
sp1.Visible = true;
lblError.Text = "<i class=\"fa fa-exclamation-triangle fcRed\"></i> هذا البريد الالكتروني غير مسجل في النظام";
return;
}
string body = "<h2>";
body += "هذة معلومات الدخول الى لوحة التحكم الخاصة بموقع الدليل الاإلكتروني لإرشفة القرارات و التعاميم الحكومية<br/>";
body += "اسم المستخدم : " + dt.Rows[0]["username"].ToString() + "<br/>";
body += "البريد الالكتروني : " + dt.Rows[0]["email"].ToString() + "<br/>";
body += "كلمة السر : " + dt.Rows[0]["password"].ToString() + "<br/>";
body += "</h2>";
SendMail mail = new SendMail();
mail.SendMsg(txtEmail.Text, "الدليل الاإلكتروني لإرشفة القرارات و التعاميم الحكومية", body);
ScriptManager.RegisterClientScriptBlock(this,GetType(), "writeMsg", "alert('تم ارسال كلمة السر الي البريد الالكتروني " + txtEmail.Text + " ');", true);
}
示例10: GetData
private void GetData(string name,DateTime? date)
{
Database db = new Database();
Lang lang = new Lang();
string sqlSearch = "select * from Event where [email protected]";
db.AddParameter("@lang", lang.getCurrentLang());
if (!string.IsNullOrWhiteSpace(name))
{
sqlSearch += " and title like '%' + @name + '%'";
db.AddParameter("@name", name);
}
if (date.HasValue)
{
sqlSearch += " and (year(EventDate)[email protected] and month(EventDate)[email protected] and day(EventDate)[email protected] )";
db.AddParameter("@year",date.Value.Year);
db.AddParameter("@month", date.Value.Month);
db.AddParameter("@day", date.Value.Day);
}
DataTable dt = db.ExecuteDataTable(sqlSearch);
ListView1.DataSource = dt;
ListView1.DataBind();
}
示例11: LoadFavFiles
private void LoadFavFiles(string userId)
{
Database db=new Database();
db.AddParameter("@id", userId);
DataTable dt = db.ExecuteDataTable("select files.* from UserFav inner join files on (Files.Id=UserFav.FileId) where [email protected]");
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
示例12: LoadMsg
private void LoadMsg()
{
Users u = Session["User"] as Users;
Database db = new Database();
db.AddParameter("@to", u.Id);
DataTable dt = db.ExecuteDataTable("select msg.*,Users.name as username from (Msg left join users on (users.id=msg.[from]) ) where [email protected] order by msg.Id desc");
ListView1.DataSource = dt;
ListView1.DataBind();
}
示例13: GetData
private void GetData()
{
Database db = new Database();
Lang lang = new Lang();
db.AddParameter("@lang", lang.getCurrentLang());
DataTable dt = db.ExecuteDataTable("select * from Socialevent where [email protected]");
ListView1.DataSource = dt;
ListView1.DataBind();
}
示例14: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LoadData();
Database db = new Database();
Lang lang = new Lang();
db.AddParameter("@lang", lang.getCurrentLang());
DataTable dt = db.ExecuteDataTable("select top(3) * from SocialEvent where [email protected] Order by id desc");
Repeater2.DataSource = dt;
Repeater2.DataBind();
db.AddParameter("@lang", lang.getCurrentLang());
dt = db.ExecuteDataTable("select top(3) * from news where [email protected] Order by id desc");
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
}
示例15: LoadData
private void LoadData()
{
Database db = new Database();
Lang lang = new Lang();
db.AddParameter("@lang", lang.getCurrentLang());
DataTable dt = db.ExecuteDataTable("select * from Publications where [email protected] Order by id desc");
ListView1.DataSource = dt;
ListView1.DataBind();
}