SQL Server Compact Edition ISNULL(sth, ' ') returns a boolean value?
10,985
According this ISNULL
is not implemented in SQL Server CE. I would expect to see a syntax error raised, however.
Workaround: you can use CASE WHEN email IS NULL THEN 'eeee' ELSE email END
or COALESCE
. Preferably the latter.
Also use parameterised queries. If you don't know why you should, learn.
Author by
Ada
Updated on July 04, 2022Comments
-
Ada almost 2 years
I have an
Accounts
table with columnsname, password
andemail
. They are all typenvarchar
. I wrote a query likeSELECT name, password, ISNULL(email, 'eeee') FROM Accounts WHERE name = '" + textBox1.Text + "' AND password ='" + textBox2.Text + "'"
I read the email as
reader.getString(2)
since it isnvarchar
.As I read from the internet, if
email
is NULL, then it should returneeee
. But it saysSystem.boolean
can not be translated toSystem.String
.How can I correct this? Why does it return a boolean value?
-
Ada about 13 yearsthank you it worked. I will accept your answer as soon as the 4 mins passed.