?
Solved

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

Posted on 2008-11-17
3
Medium Priority
?
875 Views
Last Modified: 2013-11-11
Hello,

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

        Try
            For Each User In People ' <----------- Error
                MsgBox(User.AuthorID)
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        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...

tnx
~j
0
Comment
Question by:NCSO
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
ChetOS82 earned 2000 total points
ID: 22977117
Check out http://dotnetslackers.com/XLinq/re-63043_LINQ_Error_String_must_be_exactly_one_character_long.aspx

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

Author Comment

by:NCSO
ID: 22978819
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" />

to:

<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.

tnx
~j
0
 

Author Closing Comment

by:NCSO
ID: 31517468
This actually wasn't the answer to my question but got me on the right track.

Check my final comment for the actual answer!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

840 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