Linq query: "String must be exactly one character long"

Posted on 2008-11-17
Last Modified: 2013-11-11

This simple Linq query gives me an error "String must be exactly one character long" on the specified line:

        Dim db As New DataClasses1DataContext
        Dim People = From tblPeople In db.tblLogins

            For Each User In People ' <----------- Error
        Catch ex As Exception
        End Try

If I "Set Next Statement" before the Try AFTER receiving the error it get the content of the database just fine...  

What's going on...

Question by:NCSO
    LVL 18

    Accepted Solution

    Check out

    You need to change the definition from Char(1) to String in the designer.

    Author Comment

    I actually found this article myself but couldn't find anything useful, except the necessary change is in the DBML file instead.

    I changed this line:

    <Column Name="MI" Type="System.Char" DbType="Char" CanBeNull="true" />


    <Column Name="MI" Type="System.String" DbType="NVarChar(1)" CanBeNull="true" />

    And all is good in the world!

    But you got me on the right track, so I'm happy.


    Author Closing Comment

    This actually wasn't the answer to my question but got me on the right track.

    Check my final comment for the actual answer!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now