问题描述
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个让你拿了?