2

When you get this error "Character constant must contain exactly one character"

I had this code but it constant gave me the above error in my LinqDataSource:

 <asp:LinqDataSource ID="LinqViewLogs" runat="server" 
    ContextTypeName="ScanFakDataContext" OrderBy="Dato desc" 
    TableName="ViewLogs" 
        Where="(@Filter='' OR (@Filter='UserNotes' AND LogType=1)">
     <WhereParameters>
         <asp:QueryStringParameter DbType="String" DefaultValue="" Name="Filter" QueryStringField="Filter" />
     </WhereParameters>
</asp:LinqDataSource>
JanBorup
  • 5,337
  • 1
  • 29
  • 17

1 Answers1

1

The problem was to reverse the quotes, so "" is '', and '' was ""

Here is the correct code:

 <asp:LinqDataSource ID="LinqViewLogs" runat="server" 
    ContextTypeName="ScanFakDataContext" OrderBy="Dato desc" 
    TableName="ViewLogs" 
        Where='(@Filter="" OR (@Filter="UserNotes" AND LogType=1)'>
     <WhereParameters>
         <asp:QueryStringParameter DbType="String" DefaultValue="" Name="Filter" QueryStringField="Filter" />
     </WhereParameters>
</asp:LinqDataSource>
Habib
  • 219,104
  • 29
  • 407
  • 436
JanBorup
  • 5,337
  • 1
  • 29
  • 17
  • I had this error in Business Intelligence (Reporting Services) and I was not using single quotes inside double quoted strings, but after searching for a while, your answer allowed me to understand that one of the column's expressions used in my report had a couple of extra `"` which was causing the error. I removed them and the error was gone. Thank you! (btw you can accept your own answer) – CPHPython Jul 28 '16 at 13:23