首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

出现错误

2012-01-24 
出现异常usingSystemusingSystem.DatausingSystem.ConfigurationusingSystem.WebusingSystem.Web.Secu

出现异常
using   System;
using   System.Data;
using   System.Configuration;
using   System.Web;
using   System.Web.Security;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.WebControls.WebParts;
using   System.Web.UI.HtmlControls;
using   System.Data.SqlClient;
public   partial   class   _Default   :   System.Web.UI.Page  
{
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                string   No   =   " ";
                string   Name   =   " ";
                string   Lesson   =   " ";
                string   Msg   =   " ";
                if   (IsPostBack)
                {
                        No=Request[ "txtNo "];
                        Name=Request[ "txtName "];
                        Lesson=Request[ "Lesson "];
                        string   SQL   =   "select   *   from   成绩单 ";
                        SQL   =   SQL   +   "where   学号= "   +   " ' "   +   No   +   " ' "   +   "and   姓名= ' "   +   Name   +   " ' ";
                        SqlConnection   Conn   =   new   SqlConnection( "server=.;database=test;uid=sa;pwd=chaustar ");
                          Conn.Open();
                        SqlCommand   Comm   =   new   SqlCommand(SQL,Conn);
                        SqlDataReader   dr   =   Comm.ExecuteReader();
                        if   (dr.Read())
                        {
                                if   (dr[Lesson].ToString()   !=   "-1 ")
                                {
                                        Msg   =   "你已经考过本科目了! ";
                                }
                                else
                                {


                                        Conn.Close();
                                        Response.Redirect( "test.aspx?   Lesson= "   +   Lesson   +   "&Name= "   +   Name   +   "&No= "   +   No);
                                }
                        }

                        else
                        {
                                Msg   =   "你不是合法考生! ";
                        }
                        Message.Text   =   Msg;
                        Conn.Close();
                }
        }
}
错误描述:行   29:   SqlDataReader   dr   =   Comm.ExecuteReader();“=”附近有语法错误,各位看看是什么问题呀?


[解决办法]
sql 语句有问题

[解决办法]
支持,SQL有问题,语言的本身并没有错
[解决办法]
检查 sql语句
[解决办法]
string SQL = "select * from 成绩单 ";
SQL = SQL + "where 学号= " + " ' " + No + " ' " + "and 姓名= ' " + Name + " ' ";
改成
string SQL = "select * from 成绩单 ";
SQL = SQL + "where 学号= " + " ' " + No + " ' " + "and 姓名= ' " + Name + " ' ";

成绩单后面加上一个空格

热点排行