大神求解啊!!!System.Data.SqlClient.SqlException: 传递到 SUBSTRING 函数的长度参数无效。

问题描述

Seetheendofthismessagefordetailsoninvokingjust-in-time(JIT)debugginginsteadofthisdialogbox.**************ExceptionText**************System.Data.SqlClient.SqlException:传递到SUBSTRING函数的长度参数无效。atSystem.Data.SqlClient.SqlConnection.OnError(SqlExceptionexception,BooleanbreakConnection)atSystem.Data.SqlClient.SqlInternalConnection.OnError(SqlExceptionexception,BooleanbreakConnection)atSystem.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObjectstateObj)atSystem.Data.SqlClient.TdsParser.Run(RunBehaviorrunBehavior,SqlCommandcmdHandler,SqlDataReaderdataStream,BulkCopySimpleResultSetbulkCopyHandler,TdsParserStateObjectstateObj)atSystem.Data.SqlClient.SqlDataReader.HasMoreRows()atSystem.Data.SqlClient.SqlDataReader.ReadInternal(BooleansetTimeout)atSystem.Data.SqlClient.SqlDataReader.Read()atSystem.Data.Common.DataAdapter.FillLoadDataRow(SchemaMappingmapping)atSystem.Data.Common.DataAdapter.FillFromReader(DataSetdataset,DataTabledatatable,StringsrcTable,DataReaderContainerdataReader,Int32startRecord,Int32maxRecords,DataColumnparentChapterColumn,ObjectparentChapterValue)atSystem.Data.Common.DataAdapter.Fill(DataSetdataSet,StringsrcTable,IDataReaderdataReader,Int32startRecord,Int32maxRecords)atSystem.Data.Common.DbDataAdapter.FillInternal(DataSetdataset,DataTable[]datatables,Int32startRecord,Int32maxRecords,StringsrcTable,IDbCommandcommand,CommandBehaviorbehavior)atSystem.Data.Common.DbDataAdapter.Fill(DataSetdataSet,Int32startRecord,Int32maxRecords,StringsrcTable,IDbCommandcommand,CommandBehaviorbehavior)atSystem.Data.Common.DbDataAdapter.Fill(DataSetdataSet,StringsrcTable)atLibManClient.DBManage.OpenRecordSet(Stringsql,StringxmlTableName)atLibManClient.BookCatalogue.CheckClassIndex(StringstrClassIndex)atLibManClient.frmQEditBook.CheckClassCode()atLibManClient.frmQEditBook.textBox20_Leave(Objectsender,EventArgse)atSystem.Windows.Forms.Control.OnLeave(EventArgse)atSystem.Windows.Forms.Control.NotifyLeave()atSystem.Windows.Forms.ContainerControl.UpdateFocusedControl()**************LoadedAssemblies**************mscorlibAssemblyVersion:2.0.0.0Win32Version:2.0.50727.3623(GDR.050727-3600)CodeBase:file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll----------------------------------------LibManClientAssemblyVersion:1.0.0.0Win32Version:1.0.0.0CodeBase:file:///C:/Program%20Files/LibraryMgt/LibManClient/LibManClient.exe----------------------------------------BookBaseModeAssemblyVersion:1.0.2495.20186Win32Version:1.0.2495.20186CodeBase:file:///C:/Program%20Files/LibraryMgt/LibManClient/BookBaseMode.DLL----------------------------------------System.Windows.FormsAssemblyVersion:2.0.0.0Win32Version:2.0.50727.3623(GDR.050727-3600)CodeBase:file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll----------------------------------------SystemAssemblyVersion:2.0.0.0Win32Version:2.0.50727.3624(GDR.050727-3600)CodeBase:file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll----------------------------------------System.DrawingAssemblyVersion:2.0.0.0Win32Version:2.0.50727.3053(netfxsp.050727-3000)CodeBase:file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll----------------------------------------System.XmlAssemblyVersion:2.0.0.0Win32Version:2.0.50727.3082(QFE.050727-3000)CodeBase:file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll----------------------------------------System.DataAssemblyVersion:2.0.0.0Win32Version:2.0.50727.3053(netfxsp.050727-3000)CodeBase:file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll----------------------------------------System.ConfigurationAssemblyVersion:2.0.0.0Win32Version:2.0.50727.3053(netfxsp.050727-3000)CodeBase:file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll----------------------------------------System.TransactionsAssemblyVersion:2.0.0.0Win32Version:2.0.50727.3053(netfxsp.050727-3000)CodeBase:file:///C:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll----------------------------------------System.EnterpriseServicesAssemblyVersion:2.0.0.0Win32Version:2.0.50727.3053(netfxsp.050727-3000)CodeBase:file:///C:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll----------------------------------------AccessibilityAssemblyVersion:2.0.0.0Win32Version:2.0.50727.3053(netfxsp.050727-3000)CodeBase:file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll----------------------------------------System.Web.ServicesAssemblyVersion:2.0.0.0Win32Version:2.0.50727.3053(netfxsp.050727-3000)CodeBase:file:///C:/WINDOWS/assembly/GAC_MSIL/System.Web.Services/2.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll----------------------------------------kpsknsbzAssemblyVersion:1.0.2495.20186Win32Version:2.0.50727.3624(GDR.050727-3600)CodeBase:file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll----------------------------------------FlexCellAssemblyVersion:1.6.6.0Win32Version:1.6.6.0CodeBase:file:///C:/Program%20Files/LibraryMgt/LibManClient/FlexCell.DLL----------------------------------------Microsoft.VisualBasicAssemblyVersion:8.0.0.0Win32Version:8.0.50727.3053(netfxsp.050727-3000)CodeBase:file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll----------------------------------------**************JITDebugging**************Toenablejust-in-time(JIT)debugging,the.configfileforthisapplicationorcomputer(machine.config)musthavethejitDebuggingvaluesetinthesystem.windows.formssection.Theapplicationmustalsobecompiledwithdebuggingenabled.Forexample:<configuration><system.windows.formsjitDebugging="true"/></configuration>WhenJITdebuggingisenabled,anyunhandledexceptionwillbesenttotheJITdebuggerregisteredonthecomputerratherthanbehandledbythisdialogbox.

解决方案

解决方案二:
这问题没具体的sql无解……
解决方案三:
空库的时候一切都正常,就是把数据导入到库里之后就报这个错误!
解决方案四:
引用1楼starfd的回复:

这问题没具体的sql无解……

空库的时候一切都正常,就是把数据导入到库里之后就报这个错误!
解决方案五:
LibManClient.BookCatalogue.CheckClassIndex处的代码?以及断点调试、调用LibManClient.DBManage.OpenRecordSet()时参数的值?
解决方案六:
引用4楼Tiger_Zhao的回复:

LibManClient.BookCatalogue.CheckClassIndex处的代码?以及断点调试、调用LibManClient.DBManage.OpenRecordSet()时参数的值?

源程序安装初始使用都没问题的,就把数据库里数据恢复到库里的时候就报这个错误了!求解!
解决方案七:
没代码,也没sql语句,鬼知道为什么如果之前是好的,恢复数据之后坏了那检查数据啊,看到底怎么了
解决方案八:
引用6楼Z65443344的回复:

没代码,也没sql语句,鬼知道为什么如果之前是好的,恢复数据之后坏了那检查数据啊,看到底怎么了

解决方案九:
这段代码和错误又关系!!!
解决方案十:
这段代码和错误又没关系!!!
解决方案十一:
传递到SUBSTRING函数的长度参数无效这已经说的很清楚了,你给SUBSTRING()的最后一个长度参数有问题,应该是越界了你的SubLen必须要小于Len,所以:While@SubLen<@Len+1改为:While@SubLen<@Len
解决方案十二:
SUBSTRING(@Code,1,@Sublen)

其实并不是SubLen必须小于Len而是SubLen+偏移量必须<=Len你偏移量是1(从1开始取子字符串,而不是0)那么最多只能取到Len-1,而不能取到Len同理,你从n开始取,最多也只能取出Len-n个字符
解决方案十三:
举个直白的例子一共有100个苹果从第50个开始拿,拿走50个,是可以的从第51个开始拿,也有50个可拿从第99个开始拿,还哪里有50个让你拿了?

时间: 2024-08-30 21:09:39

大神求解啊!!!System.Data.SqlClient.SqlException: 传递到 SUBSTRING 函数的长度参数无效。的相关文章

捕捉到 System.Data.SqlClient.SqlException Message=对象名 &amp;amp;#x27;&amp;amp;#x27; 无效

问题描述 建立的Connecting的链接,数据是指向A.我现在通过A的数据库链接要向B数据库中写入数据(A和B是在同一台服务器上.)代码如下MasterCmd=newSqlCommand("select*fromB..p_materialwheretParentId=101",db.thisSqlconnection);MasterAdapter=newSqlDataAdapter();MasterAdapter.SelectCommand=MasterCmd;MasterDt=ne

System.Data.SqlClient.SqlException: &amp;amp;#x27;System&amp;amp;#x27; 附近有语法错误。

问题描述 usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Data.SqlClient;usingSystem.Data;namespaceWebApplication1{publicpartialclasswjdc_xs1:System.Web.UI.Page{pro

new-求解!!“System.Data.SqlClient.SqlException”类型的异常

问题描述 求解!!"System.Data.SqlClient.SqlException"类型的异常 使用vs调试网站时候出现一下问题. "System.Data.SqlClient.SqlException"类型的异常在 System.Data.dll 中发生,但未在用户代码中进行处理 其他信息: 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误.未找到或无法访问服务器.请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接

System.Data.SqlClient.SqlException 超时时间已到

错误信息: 有关调用实时(JIT)调试而不是此对话框的详细信息, 请参见此消息的结尾. ************** 异常文本 ************** System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Timeout 时间已到.在操作完成之前超时时间已过或服务器未响应. (错误详细信息等于 很可能由 IncludeExceptionDetailInFaults=true 创建的 Except

System.Data.SqlClient.SqlException: 数据类型 text 和 varchar 在 equal to 运算符中不兼容。

一.引起的源头 环境:vs2015,sqlserver2008 相关程序包:ef6 定义了一个实体article public class Article { public string Data{get;set;} } EntityTypeConfiguration的配置 Property(a => a.Data).IsRequired().HasColumnType("text"); 这样可以正常生成表字段,而且类型也正确插入数据的时候,就引起了以下异常 System.Dat

System.Data.SqlClient.SqlException: 无法打开登录所请求的数据库

  问题是这样的...我在VS2008直接运行打开网页,可以连接数据库...但通过输入地址,也可以打开网页,但涉及数据库就出问题... 无法打开登录所请求的数据库 "TakeClass".登录失败. 用户 '2D2727E2578F446ASPNET' 登录失败. 说明: 执行当前 Web 请求期间,出现未处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息. 异常详细信息: System.Data.SqlClient.SqlException: 无法打开

LINQToDataTable报错,System.Data.SqlClient.SqlException (0x80131904): Timeout 时间已到。

问题描述 System.Data.SqlClient.SqlException(0x80131904):Timeout时间已到.在操作完成之前超时时间已过或服务器未响应.--->System.ComponentModel.Win32Exception(0x80004005):等待的操作过时.在System.Data.SqlClient.SqlConnection.OnError(SqlExceptionexception,BooleanbreakConnection,Action`1wrapCl

调试中显示了System.Data.SqlClient.SqlException”类型的第一次机会异常在 System.Data.dll 中发生 的错误

问题描述 代码如下,查询不到数据库内的内容,总显示"没有成绩",报错调试中显示了System.Data.SqlClient.SqlException"类型的第一次机会异常在System.Data.dll中发生的错误sql语句是对的,在sqlserver里面试过可以查询代码如下:usingSystem;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Configuration;usingSystem.Collect

System.Data.SqlClient.SqlException: 无法打开登录所请求的数据库 登录失败。_实用技巧

问题是这样的...我在VS2008直接运行打开网页,可以连接数据库...但通过输入地址,也可以打开网页,但涉及数据库就出问题... 无法打开登录所请求的数据库 "TakeClass".登录失败. 用户 '2D2727E2578F446\ASPNET' 登录失败. 说明: 执行当前 Web 请求期间,出现未处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息. 异常详细信息: System.Data.SqlClient.SqlException: 无法打开登