当前位置: 代码迷 >> ASP.NET >> 用户代码未处理 System.Data.SqlClient.SqlException 的有关问题,求教育?
  详细解决方案

用户代码未处理 System.Data.SqlClient.SqlException 的有关问题,求教育?

热度:9985   发布时间:2013-02-25 00:00:00.0
用户代码未处理 System.Data.SqlClient.SqlException 的问题,求教育??急急
用户代码未处理 System.Data.SqlClient.SqlException
  Message=插入错误: 列名或所提供值的数目与表定义不匹配。
  Source=.Net SqlClient Data Provider
  ErrorCode=-2146232060
  Class=16
  LineNumber=1
  Number=213
  Procedure=""
  Server=.
  State=1
  StackTrace:
       在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
       在 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       在 System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
       在 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
       在 System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
       在 manages_addNew.BttTijiao_Click(Object sender, EventArgs e) 位置 i:\ProJ\manages\addNew.aspx.cs:行号 22
       在 System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       在 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       在 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException: 

------最佳解决方案--------------------------------------------------------
检查一下你的Insert语句吧,根据错误信息来判断是那里出了错误
------其他解决方案--------------------------------------------------------
SQL语句有问题,你把语句放进数据库执行一下,你就知道了,
------其他解决方案--------------------------------------------------------
这个错误的意思是这样的,举例如下:
数据库表A有两个字段a,b ,程序员却尝试
insert into A values (a,b,c) 
就是你要insert的表提供的字段必须和数据库表的列相匹配
------其他解决方案--------------------------------------------------------
我的数据库表是一个New表 ,字段有NEWID,author,tile,readcount,addtime,contents,6个字段,我在添加新闻时只设置author,tile,addtime,contents,三个字段,其他的不用添加也行吧 

------其他解决方案--------------------------------------------------------
引用:
我的数据库表是一个New表 ,字段有NEWID,author,tile,readcount,addtime,contents,6个字段,我在添加新闻时只设置author,tile,addtime,contents,三个字段,其他的不用添加也行吧
各位请指教了!!
------其他解决方案--------------------------------------------------------
添加新闻的界面

------其他解决方案--------------------------------------------------------
  相关解决方案