qq_28684017
背过手!
2015-12-11 07:13

新手ASP.NET编程问题求解

  • c#
  • asp.net
  • 编程
  • vs2013

列名 'zz' 无效。

说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Data.SqlClient.SqlException: 列名 'zz' 无效。

源错误:

行 27: SqlCommand comm = new SqlCommand(sql1, conn);
行 28: DataSet ds = new DataSet();
行 29: SqlDataReader dr = comm.ExecuteReader();
行 30: if (dr.Read())
行 31: {

源文件: f:\C#\注册登陆\用户页面.aspx.cs 行: 29

堆栈跟踪:

[SqlException (0x80131904): 列名 'zz' 无效。]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) +2436614
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction) +5731148
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +628
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +3731
System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +58
System.Data.SqlClient.SqlDataReader.get_MetaData() +89
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +379
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +2026
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +375
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +53
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +240
System.Data.SqlClient.SqlCommand.ExecuteReader() +99
Default2.Page_Load(Object sender, EventArgs e) in f:\C#\注册登陆\用户页面.aspx.cs:29
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +95
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2952

版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.6.1038.0

    SqlConn sc = new SqlConn();
    protected void Page_Load(object sender, EventArgs e)
{
    Label10.Text=Session["name"].ToString();
    string sql1 = "select * from XX where Name=" + Session["name"] + "";
    SqlConnection conn = sc.getSqlConnection();
    conn.Open();

    SqlCommand comm = new SqlCommand(sql1, conn);
    DataSet ds = new DataSet();
    SqlDataReader dr = comm.ExecuteReader();
    if (dr.Read())
    {
        this.Label11.Text = dr.GetString(dr.GetOrdinal("Nicename"));
        this.Label12.Text = dr.GetString(dr.GetOrdinal("Sex"));
        this.Label13.Text = dr.GetString(dr.GetOrdinal("PhoneNumber"));
        this.Label14.Text = dr.GetString(dr.GetOrdinal("Email"));
    }


  • 点赞
  • 收藏
  • 复制链接分享

5条回答

为你推荐

换一换