Connecting Tech Pros Worldwide Forums | Help | Site Map

Nchars as PrimaryKeys

markmcgookin's Avatar
Moderator
 
Join Date: Dec 2006
Location: Northern Ireland / England
Posts: 546
#1: Aug 7 '07
Hi All,

I am working on a project at the moment using SQL Server CE and in my login/user details database I have a user table with the individual username as a primary key.

I am trying to query this using entityspaces LoadByPrimaryKey function, which works fine.... but only if the username is all text, if I throw a numeric character in there it always comes back false.

I can't understand this as they are all essentially characters, the DB knows they are not numeric values, and I have tried explicit convert.toString type methods on the variable being passed, but none of this seems to work.

Does anyone have any ideas/solutions to this kind of thing? Or has anyone experienced it before.

Cheers,

Mark

RedSon's Avatar
Site Moderator
 
Join Date: Jan 2007
Location: America
Posts: 3,392
#2: Aug 8 '07

re: Nchars as PrimaryKeys


Is your database expecting a buffer of chars but you throw a number in there and interprets it as a value thereby making the array invalid?

This sounds more like a database engine problem then a embedded/mobile problem. What database are you using?
markmcgookin's Avatar
Moderator
 
Join Date: Dec 2006
Location: Northern Ireland / England
Posts: 546
#3: Aug 13 '07

re: Nchars as PrimaryKeys


Quote:

Originally Posted by RedSon

Is your database expecting a buffer of chars but you throw a number in there and interprets it as a value thereby making the array invalid?

This sounds more like a database engine problem then a embedded/mobile problem. What database are you using?

It was SQL Server CE 3.0. I still have no idea why it was happening, but fortunatly I solved another problem that was forcing me to use the Nchar as the PK and now have a uniqueidentifier guid based entity, thus avoiding having to deal with this problem! hehe :P
Reply