Note that there are some explanatory texts on larger screens.

plurals
  1. POSharepoint 2007: Value does not fall within the expected range
    primarykey
    data
    text
    <p>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:</p> <pre><code>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 &lt; 2 Then curMonth = "0" &amp; curMonth End If Dim curDay As String = Now.Day.ToString If curDay.Length &lt; 2 Then curDay = "0" &amp; curDay End If Dim curObsPrefix As String = "E" &amp; curYear &amp; "-" &amp; curMonth &amp; "-" 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 = "&lt;Where&gt;&lt;BeginsWith&gt;&lt;FieldRef Name='Exclusion_x0020__x0023_' /&gt;" &amp; _ "&lt;Value Type='Text'&gt;" &amp; curObsPrefix &amp; "&lt;/Value&gt;" &amp; _ "&lt;/BeginsWith&gt;&lt;/Where&gt;&lt;OrderBy&gt;&lt;FieldRef Name='Exclusion_x0020__x0023_' Ascending='False' /&gt;&lt;/OrderBy&gt;" Dim listItems As spListItemCollection = list.getItems(query) Dim newReportNo As Integer = 1 If listItems IsNot Nothing AndAlso listItems.count &gt; 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:" &amp; 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 &lt; 3 lic = "0" &amp; lic End While Return prefix &amp; lic End Function End Class </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload