|
Well, the problem was, that I'm fetching data from database and sometimes it is Null, not Nothing.
So the simple "if a <> b" will look like:
If a <> b or (IsNull(a) and not IsNull(b)) or (not IsNull(a) and IsNull(b))
And this is nonsence. How can one say that "Null <> 12" is false? Ok, I heard from someone that Null is not nothing, but everything. But in such case the statement "Null = 12" should be true. But it is not.
I know, I know, I found a documentation on this. It says that comparing to Null always returns False. For example Oracle uses same comparision as VB. But why?... as I said, it doesn't make sence at all.
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Oh and forgot.
Why it cannot be compared? Maybe I'm looking at VB from my C++ position, but still... The computer has only 1 or 0, ON or OFF, that's all. No third part. Suddenly I see that VB, Oracle and maybe some other products pushes out a new state... what is that? 1.5? A half turned ON? ROTFL
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Philip Patrick wrote:
The computer has only 1 or 0
When things don't work right it makes you question if it's writing a 2 between the 1 and 0's sometimes huh.
If you are at all concerned that you may possess a Null value in one of your variables you should use the isnull([YourVariableHere]) built-in function to check, don't say <> to some other variable.
Nick Parker
|
|
|
|
|
Nick Parker wrote:
you should use the isnull
But look my previous post, what kind of "If" I'm getting because of this.
Guys, C++ rulez
In VB, Oracle (SQL Server also, I checked it) developers made a phylosophy, but this is a world of Mathematics, there is no place of thought what is "null" or "nothing". I'm really disapointed
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Its got nothing to do with VB, its to do with databases. If a database field has no value it is NULL. You can setup database rules to allow or disallow this. That is different from saying that the field has an empty string, or a 0.
To get around the problem, either make the field not allow nulls (if that is okay by your schema), or for strings, you can use Trim(rs("a") & " ") which will return an empty string if the field is null, or if its an empty string.
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
I know, I know. I already found a solution in my code. But still don't understand why simple "Null <> 12" returns false. Just don't see logic behind this
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Philip Patrick wrote:
I'm really disapointed
Sorry to upset but there are only so many ways that you can check something, in VB or C++. Good Luck.
Nick Parker
|
|
|
|
|
In most languages that properly supports them (e.g. SQL), null values are a kind of "dead end" values. Every expression that involves a null value should become null or a type cast error. It varies from language to language what's a type cast error or a null, but the principle is the same:
So, Null + 12 results Null
Null * 2 results Null
Null == 12 results Null.
Null == Null results Null.
Well, VBScript automatically casts Null to a boolean False, so both checks fail.
Try with SQL (any decent SQL implementation) and you'll get the same results.
In fact, in SQL you should use "IS NULL" and not "= NULL" in queries. This is a common bug I see.
Crivo
Automated Credit Assessment
|
|
|
|
|
Yep, I realized that. The last language I still didn't checked is Pascal (let me come home, I'll do that )
Now I see, that developers of programming languages thought about humans and not about computers and Math.
Null <> 12 should be True and doesn't matter what you mean by Null. But someone assumed that all operations with Null should return Null. I can't accept it, because it is a human's view, not computer's
So again.... C++ Rulez (sorry for kidding )
In C++ NULL != 12 is true as it should be
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Philip Patrick wrote:
In C++ NULL != 12 is true as it should be
Ah, but in C++ NULL HAS a value (0 or (void*) 0 ), NULL should not have a value because that is what it means, no value.
When you compare something to NULL in C++ you are checking whether the pointer is pointing to memory location 0.
James
Simplicity Rules!
|
|
|
|
|
Any Null operations will result in Null (e.g. Null<>12=Null and [Null=12]=Null)...and in If null is coerced into False
|
|
|
|
|
Well, many people (and myself also) already said this.
Now another question. If you can't compare to Null, so why you can cast it to Boolean?
And if you can cast Null to Boolean, you can or sure cast it to Integer. So the result should look like (I'll use C++ syntax, it has castings)
if( ((int)(bool)NULL) <> (int)12 ) ...
You see now? You can compare to Null
Maybe I'm stubborn, but still it doesn't make sence to me
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
James T. Johnson wrote:
NULL should not have a value
Why not? You can't implement it in computer without some sort of philosophy. If no one knows what is NULL, so why it is not 0?
Again, it doesn't matter what it is, 0 or -1 or 980987. You have to agree that Null (whatever it be) is not 12
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Philip Patrick wrote:
Why not?
That is the definition of NULL when dealing with databases, no value. To give a value to NULL is a hack.
Philip Patrick wrote:
If no one knows what is NULL, so why it is not 0?
We know what NULL is, NULL is the state of not having a value
Philip Patrick wrote:
Again, it doesn't matter what it is, 0 or -1 or 980987
Sure it does, if Age is a nullable column in a database an age of 0 has a different meaning than no value. That is its entire purpose.
Philip Patrick wrote:
You have to agree that Null (whatever it be) is not 12
In the original post you were using equals to compare two values, any value compared to Null is Null, not true or false; but thanks to VB's implicit casting [ ] you get a false out of it.
Something I neglected to mention in my previous post was the Database NULL and C++ NULL stand for two different things. Database NULL means no value, C++ NULL means a pointer to memory location 0, obviously a value.
James
Simplicity Rules!
|
|
|
|
|
James T. Johnson wrote:
any value compared to Null is Null
And this is what I don't understand. Why it is Null? I mean the result of comparision. If it is illegal to compare to Null, so I should get an error, but not a boolean "False"
At the end I don't understand what is "nothing" in computer?
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Hello.
I need query Excel Sheets count and names
by asp.net.
How can I get access to a Excel file and it's
properties?
Can anyone help me?
Thanks in advance!!!!
Sergio
Sergio Bertini
|
|
|
|
|
Hi Recently I have downloaded the Advanced ASP Forum and Discussion board with Integrated Members System. Could you please tell me how to demo the code. I am new to this area and trying to understand the code.
Thanks
sriani
|
|
|
|
|
You've heard what I said!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
What is the advantage of using code-behind? hen should I use it and when should I use aspx ?
thanks
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Code behind allows you to seperate presentation from code. i.e. you don't need to embed asp script with html code. You can also share a code-behind module between pages. If you develop a common rountine it can used by all your pages.
|
|
|
|
|
Thank you Mark
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Anyone run into this problem?
I built a C# web app and then FTP'd it, after building in release, to a hosting server. When I try accessing the page I get an error. "Could not load type namespace.page".
Microsoft Technet says the problem is that C# Web Apps must be built if they contain code-behind modules. I checked again to make sure it was built. Still no luck. Since the article also said it occurs with C# and not VB.NET I created a simple VB.NET webapp and copied it to the deployment server. Same error.
|
|
|
|
|
Found the problem. There was no aspnet_client folder in the web root.
|
|
|
|
|
I just want to make an "Hello World" for ASP.Net. A simple file that displays to the user "Hello World" in C#... With no overhead. In ASP regular, it was easy... I just did <% Response.Write "Hello World" %>
What do I do in aspx??? I don't even know, exactly, how to tell it that I want to use C#. This is a bit overwhelming.
|
|
|
|
|
<%@ Page language="c#" runat="server" %>
<script runat="server" language="c#">
void Page_Load()
{
labelHi.Text = "Hello World";
}
</script>
<html>
<head><title>Hello</title></head>
<body>
<asp:label id="labelHi" runat="server" />
</body>
</html> That should do the trick
HTH,
James
Simplicity Rules!
|
|
|
|