473,383 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Error: "string must be exactly one character long"

I'm getting this error message when running a LINQtoSQL query. My entity
classes are as follows:

[Table(Name="Activities")]
public partial class Activity
{
#region Fields
[Column(IsPrimaryKey = true, DbType="SmallDateTime NOT NULL")]
public DateTime Activity_Date { get; set; }

[Column(IsPrimaryKey = true, DbType = "Char(1) NOT NULL",
CanBeNull=false)]
public char Activity_Type { get; set; }

[Column(DbType="TinyInt NOT NULL")]
public byte Activity_Distance {get; set; }

[Column(DbType = "Char(10) NOT NULL", CanBeNull=false)]
public string Activity_Duration {get; set; }

[Column(DbType = "Char(35) NOT NULL", CanBeNull=false)]
public string Activity_Route {get; set; }
#endregion

private EntityRef<Type_Type;

[Association(Name = "Type_Activity", Storage = "_Type",
ThisKey = "Activity_Type", OtherKey = "Type_Id",
IsForeignKey = true, DeleteRule = "NO ACTION")]

public Type Type
{
get { return this._Type.Entity; }
set { this._Type.Entity = value; }
}
}

[Table(Name="Types")]
public partial class Type
{
#region Fields
[Column(IsPrimaryKey = true, DbType = "Char(1) NOT NULL", CanBeNull
= false)]
public char Type_Id { get; set; }

[Column(DbType = "Char(8) NOT NULL", CanBeNull = false)]
public char Type_Desc { get; set; }
#endregion

private EntitySet<Activity_Activities;

[Association(Storage = "_Activities", ThisKey = "Type_Id", OtherKey
= "Activity_Type")]

public EntitySet<ActivityActivities
{
get { return this._Activities; }
set { this._Activities.Assign(value); }

I am joining on Activities.Activity_Type and Types.Type_Id.

I'd appreciate some guidance on how to overcome this error because I can't
see what I may have done incorrectly.

I don't know if it's relevant but my query is as follows:

private static void GetAct_Types(DBDataContext db)
{
var act_types =
from a in db.Activities
from t in db.Types
where a.Activity_Type == t.Type_Id
select new { a.Activity_Date,
a.Activity_Type,
t.Type_Desc,
a.Activity_Distance,
a.Activity_Duration,
a.Activity_Route};

foreach (var row in act_types)
{
Console.WriteLine("{0}\t; {1}\t; {2}\t; {3}\t; {4}",
row.Activity_Date,
row.Type_Desc,
row.Activity_Distance,
row.Activity_Duration,
row.Activity_Route);
}
}
}
}

Oct 10 '08 #1
3 8768
Paolo wrote:
[Column(DbType = "Char(8) NOT NULL", CanBeNull = false)]
public char Type_Desc { get; set; }
Types don't match. CHAR(8) does not fit in a char.

--
J.
Oct 10 '08 #2
Jeroen: I'm joining on Activity_Type and Type_Id, both of which are Char(1).

"Jeroen Mostert" wrote:
Paolo wrote:
[Column(DbType = "Char(8) NOT NULL", CanBeNull = false)]
public char Type_Desc { get; set; }

Types don't match. CHAR(8) does not fit in a char.

--
J.
Oct 11 '08 #3
Jeroen: oops, I see what you're saying. Type_Desc needs to be string.

Thanks

"Jeroen Mostert" wrote:
Paolo wrote:
[Column(DbType = "Char(8) NOT NULL", CanBeNull = false)]
public char Type_Desc { get; set; }

Types don't match. CHAR(8) does not fit in a char.

--
J.
Oct 11 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: MLH | last post by:
Is an apostrophe a character of special significance to MySQL in a way that would cause "Bob's dog" to become translated into a 12-character string when typed into a MySQL memo field? If I type...
23
by: Rogers | last post by:
I want to compare strings of numbers that have a circular boundary condition. This means that the string is arranged in a loop without an end-of-string. The comparaison of two strings now...
9
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but...
4
by: Newsgroups | last post by:
Does anyone know what the VB.NET equivalent to the VB 6.0 String Function is?
3
by: Petr Jakes | last post by:
Hi, I am trying to convert string to the "escaped string". example: from "0xf" I need "\0xf" I am able to do it like: a="0xf" escaped_a=("\%s" % a ).decode("string_escape") But it looks a...
35
by: pinkfloydhomer | last post by:
How do I check if a string contains (can be converted to) an int? I want to do one thing if I am parsing and integer, and another if not. /David
10
by: =?Utf-8?B?RWxlbmE=?= | last post by:
I am surprised to discover that c# automatically converts an integer to a string when concatenating with the "+" operator. I thought c# was supposed to be very strict about types. Doesn't it seem...
5
by: mvmashraf | last post by:
Hi to all.... I have spent some time browsing for a solution to the following error but have unfortunatly not found any solution yet ,Please any help would be much appreciated.......
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.