问题描述
- 新手ASP.NET编程问题求解
-
列名 '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
1 wrapCloseInAction) +5731148
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
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")); }
解决方案
sql语句估计有错误,你把最终的sql打印出来看看
解决方案二:
Asp.net新手开发问题
ASP.NET编程中遇到的问题
ASP.Net编程问题总结
解决方案三:
console.writeLine(sql)
解决方案四:
sql语句insert检查是不是有了'zz'列。
解决方案五:
核查数据库表对应表中是否有'zz'列
解决方案六:
数据库应该已经修改过了,但SQL语句没有修改
解决方案七:
数据库应该已经修改过了,但SQL语句没有修改
解决方案八:
数据库应该已经修改过了,但SQL语句没有修改
解决方案九:
数据库应该已经修改过了,但SQL语句没有修改
解决方案十:
数据库应该已经修改过了,但SQL语句没有修改