码迷,mamicode.com
首页 > 数据库 > 详细

asp.net LINQ防止SQL注入式攻击

时间:2016-12-18 18:15:00      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:get   object   btn   count()   username   default   ati   cti   技术分享   

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string name = txtUserName.Text;
        string pass = txtPass.Text;
        DataClassesDataContext lqDB = new DataClassesDataContext();
        var result = from v in lqDB.tbUser
                     where v.username == name && v.userpass.ToString() == pass
                     select v;
        if (result.Count() > 0)
        {
            Page.ClientScript.RegisterStartupScript(GetType(),"","alert(‘登录成功‘)",true);
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(GetType(),"","alert(‘登录失败‘)",true);
        }
    }
}

技术分享

 

asp.net LINQ防止SQL注入式攻击

标签:get   object   btn   count()   username   default   ati   cti   技术分享   

原文地址:http://www.cnblogs.com/luxiaoyao/p/6194620.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!