Sharepoint 2007:价值未落在预期范围内
我们有一个列表,在尝试向其中添加新记录时会出现上述错误。下面是该类的完整内容:
Partial Class NextExclusionNo
Inherits System.Web.UI.Page
Private listName As String = "Exclusions List"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim curYear As String = Now.Year.ToString
curYear = Mid(curYear, 3)
Dim curMonth As String = Now.Month.ToString
If curMonth.Length < 2 Then
curMonth = "0" & curMonth
End If
Dim curDay As String = Now.Day.ToString
If curDay.Length < 2 Then
curDay = "0" & curDay
End If
Dim curObsPrefix As String = "E" & curYear & "-" & curMonth & "-"
Try
Using site As New spSite("http://localhost/exclusions")
Using web As spWeb = site.openweb()
Dim list As SPList = web.Lists(listName)
Dim query As New spQuery
query.query = "<Where><BeginsWith><FieldRef Name='Exclusion_x0020__x0023_' />" & _
"<Value Type='Text'>" & curObsPrefix & "</Value>" & _
"</BeginsWith></Where><OrderBy><FieldRef Name='Exclusion_x0020__x0023_' Ascending='False' /></OrderBy>"
Dim listItems As spListItemCollection = list.getItems(query)
Dim newReportNo As Integer = 1
If listItems IsNot Nothing AndAlso listItems.count > 0 Then
Dim lastReportNo = listItems.item(0).item("Exclusion_x0020__x0023_")
Dim licBits() As String = lastReportNo.split("-")
Dim lastNo As Integer = CInt(licBits(2))
newReportNo = lastNo + 1
End If
Response.Write(getFullReportNo(newReportNo, curObsPrefix))
End Using
End Using
Catch ex As Exception
Response.Write("Error:" & ex.Message)
End Try
End Sub
Private Function getFullReportNo(ByRef licNo As Integer, ByRef prefix As String) As String
Dim lic As String = licNo.ToString
While lic.Length < 3
lic = "0" & lic
End While
Return prefix & lic
End Function
End Class
上面的内容嵌套在 Try/Catch 块中。谁能帮我诊断并修复上述代码块?非常感谢您的帮助。
We have a list that gives the above error when attempting to add a new record to it. Here's the class in it's entirety:
Partial Class NextExclusionNo
Inherits System.Web.UI.Page
Private listName As String = "Exclusions List"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim curYear As String = Now.Year.ToString
curYear = Mid(curYear, 3)
Dim curMonth As String = Now.Month.ToString
If curMonth.Length < 2 Then
curMonth = "0" & curMonth
End If
Dim curDay As String = Now.Day.ToString
If curDay.Length < 2 Then
curDay = "0" & curDay
End If
Dim curObsPrefix As String = "E" & curYear & "-" & curMonth & "-"
Try
Using site As New spSite("http://localhost/exclusions")
Using web As spWeb = site.openweb()
Dim list As SPList = web.Lists(listName)
Dim query As New spQuery
query.query = "<Where><BeginsWith><FieldRef Name='Exclusion_x0020__x0023_' />" & _
"<Value Type='Text'>" & curObsPrefix & "</Value>" & _
"</BeginsWith></Where><OrderBy><FieldRef Name='Exclusion_x0020__x0023_' Ascending='False' /></OrderBy>"
Dim listItems As spListItemCollection = list.getItems(query)
Dim newReportNo As Integer = 1
If listItems IsNot Nothing AndAlso listItems.count > 0 Then
Dim lastReportNo = listItems.item(0).item("Exclusion_x0020__x0023_")
Dim licBits() As String = lastReportNo.split("-")
Dim lastNo As Integer = CInt(licBits(2))
newReportNo = lastNo + 1
End If
Response.Write(getFullReportNo(newReportNo, curObsPrefix))
End Using
End Using
Catch ex As Exception
Response.Write("Error:" & ex.Message)
End Try
End Sub
Private Function getFullReportNo(ByRef licNo As Integer, ByRef prefix As String) As String
Dim lic As String = licNo.ToString
While lic.Length < 3
lic = "0" & lic
End While
Return prefix & lic
End Function
End Class
The above is nested within a Try/Catch block. Can anyone help me diagnose and remedy the above code block? Your help is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据我的分析,只有您指定的列名称可能会出现此错误。验证您的专栏名称并与我分享您的发现。
As per my analysis only column name which you have specified may give this error. Validate your column name and share me your findings.