tags:

views:

75

answers:

2
If txtSearchString.Text.Trim <> "" Then
        Dim searchString As String = txtSearchString.Text.Trim
        Dim results As EnumerableRowCollection(Of DataRow) = From PO In FilterPurchaseOrders().AsEnumerable() _
                      Where PO("Title") Like searchString Or PO("PONumber") Like searchString _
                      Or PO("Remarks") Like searchString Or PO("Note") Like searchString _
                      Or PO("Vendor") Like searchString Or PO("ShipTo") Like searchString _
                      Or PO("Lookup") Like searchString Or PO("BillTo") Like searchString _
                      Or PO("Status") Like searchString Or PO("Choice") Like searchString _
                        Select PO

        rgPurchaseOrders.DataSource = results
    End If

I am getting this error: error BC30205: End of statement expected.

FilterPurchaseOrders() function returns a datatable.

Whats wrong with the above code?

A: 

Well, your End If is on the same line as your assignment to your grid's datasource, but that would also result in an "If statement must have a matching End If" ... unless you have another End If after the code snippet, then you'd just get "End of statement expected." i.e.:

If txtSearchString.Text.Trim <> "" Then
        Dim searchString As String = txtSearchString.Text.Trim
        Dim results = From PO In FilterPurchaseOrders().AsEnumerable() _
                      Where PO("Title") Like searchString Or PO("PONumber") Like searchString _
                      Or PO("Remarks") Like searchString Or PO("Note") Like searchString _
                      Or PO("Vendor") Like searchString Or PO("ShipTo") Like searchString _
                      Or PO("Lookup") Like searchString Or PO("BillTo") Like searchString _
                      Or PO("Status") Like searchString Or PO("Choice") Like searchString _
                        Select PO

        rgPurchaseOrders.DataSource = results **End If**

    End If
Richard Hein
sorry my bad, End If is actually in the below line, i guess the copy paste did not work on this site. But that definitely is not a problem
Ken
A: 

SharePoint site on Dev Server was not configured to use .net 3.5. I did the following web.config changes and it started working like a charm

<system.codedom>
    <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
            <providerOption name="CompilerVersion" value="v3.5"/>
            <providerOption name="WarnAsError" value="false"/>
        </compiler>
        <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
            <providerOption name="CompilerVersion" value="v3.5"/>
            <providerOption name="OptionInfer" value="true"/>
            <providerOption name="WarnAsError" value="false"/>
        </compiler>
    </compilers>
</system.codedom>
Ken