栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

System.Data.SqlClient.SqlException:附近有语法错误

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

System.Data.SqlClient.SqlException:附近有语法错误

哪位大佬给我看看,一直说

System.Data.SqlClient.SqlException:附近有语法错误

下面是我的代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace projict1
{
    public partial class login : System.Web.UI.Page
    {
        private SqlConnection sqlcon = new SqlConnection();
        private SqlCommand sqlcmd;
        protected void Page_Load(object sender, EventArgs e)
        {
            sqlcon.ConnectionString = @"server=HE; database=Student;trusted_connection=true";
            try
            {
                sqlcon.Open();
                sqlcmd = sqlcon.CreateCommand();
            }
            catch (Exception)
            {
                Response.End();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string t_name = UserName.Text;
            string t_password = PassWord.Text;
            sqlcmd.CommandText = "select * from Student.dbo.tbl_User where username'" + t_name + "'";
            SqlDataReader sqldr = sqlcmd.ExecuteReader();
            if (sqldr.Read())
            {
                if (sqldr.GetValue(1).ToString()== t_password)
                {
                    sqlcon.Close();
                    Response.Redirect("search.aspx");
                }
                else
                {
                    Response.Write("");
                }
            }
            else {
                Response.Write("");
            }
        }
    }
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/983460.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号