I'd like to check if there is anything to return given a number to check against, and if that query returns no entries, increase the number until an entry is reached and display that entry. Currently, the code looks like this :
SELECT *
FROM news
WHERE DATEDIFF(day, date, getdate() ) <= #url.d#
ORDER BY date desc
where #u...
I have some database information stored in config.inc.php and i'm trying to use it to access the database in a class I have, but for some reason, the variables are null. heres the code:
<?php
require_once 'dbinterface.php';
require_once 'config.inc.php';
class user {
...
function user($id) {
$this->db = new db($DB['host...
I want to be able to pass in a list of parameters, and ignore the ones which are NULL. So that the query is in effect pretending that the filter isn't there and ignoring it. My problem is that the columns I'm filtering do accept NULLs, but if I use something like this, all the NULL fields are removed.
WHERE column = Case WHEN NULL colu...
I have a MySQL query that checks an employee schedule DB and (thanks to a previous stackoverflow question) returns any days that the user is not working as "No Work", so that if the user isn't working on Thursday, the query fills in that date even though the date does not appear in the original result set (and so I don't have to fill in ...
Probably a C# noob question, so don't flame me. I was trying to do this:
if (ConfigurationManager.ConnectionStrings["PrimaryConnectionString"].ConnectionString != null)
{
// ...
}
But I kept getting a System.NullReferenceException. I thought since it returns a string that I could just check for null and move on. It took me a while...
I have inherited a large c++ code base and I have a task to avoid any null pointer exceptions that can happen in the code base. Are there are static analysis tools available, I am thinking lint, that you have used successfully.
What other things do you look out for?
...
Hi all.
I have a web form (.aspx) that has a textbox.
My user can enter a value into the textbox as a persian date.
what should I do is converting texbox.text into DateTime.
But sometimes,the textbox has no text within it and so I should take care of it and return null.
when I return null how can I insert null (c#) into DB?
...
I am getting this error when I retrieve a row with a null DataTime field:
'srRow.Closed_Date' threw an exception of type 'System.Data.StrongTypingException'
How do I properly handle these?
...
I've noticed that some .NET structs can be compared to null.
For example:
TimeSpan y = new TimeSpan();
if (y == null)
return;
will compile just fine (the same with the Guid struct).
Now I know that stucts are value type and that the code above should not compile, unless there's an overload of operator == which ta...
I used to think that Oracle does not index a row when one of the column values is null.
Some simple experimentation shows this to be not the case. I was able to run some queries unexpectedly accessing only indexes even though some columns were nullable (which of course was a pleasant surprise).
A Google search led to some blogs with co...
I'm migrating data from one db to another.
I have a numeric col. that contains some values, some 0s and some nulls. My gut feeling is to convert all the 0s to NULLs. This will store an optional, user-provided number.
Any reason NOT to convert all the 0s to NULLs?
...
I'm setting up an ADO-based client dataset, and when I try to insert a null value into a TIntegerField, on Post I get Project raised exception class EDatabaseError with message 'Non-nullable column cannot be updated to Null'.
I know I've seen a way to set a TField as nullable before, but I can't remember where or how. Does anyone know ...
I think this is a bug in the WPF framework, with out going into depths of my program and why I am doing what I am doing, I wrote a simple test app to prove my theory.
Can someone confirm this issue, and suggest possible work arounds for a series of dialogs to be executed before putting the app into its run loop?
using System;
using Sys...
Let's say I have the table
NAME | ID | REF
foo1 | 1 | NULL
foo2 | 2 | 1234
foo2 | 3 | 567
foo1 | 4 | NULL
foo3 | 5 | 89
I'd like to count all instances of NULL and NOT NULL in one query so that I can say
NAME | null | not null
foo1 | 0 | 2
foo2 | 2 | 0
foo3 | 0 | 1
I could run these two queries
selec...
I've heard some voices saying that checking for a returned null value from methods is bad design. I would like to hear some reasons for this.
pseudocode:
variable x = object.method()
if (x is null) do something
...
Often I have a class as such:
public class Foo
{
private String field1;
private String field2;
// etc etc etc
}
This makes the initial values of field1 and field2 equal to null. Would it be better to have all my String class fields as follows?
public class Foo
{
private String field1 = "";
private String field2 = "";
// etc etc et...
(I know what null is and what its is used for)
Question: OK, say we make a reference to an object in whatever language. The computer makes a little 32-bit (or other size, depending on computer's design) space in memory for that reference. That memory can be assigned to a value that represents an object's location in memory. But when I s...
Possible Duplicate:
Nullable types and the ternary operator. Why wont this work?
Why doesn't this work? Seems like valid code. Can anyone help?
string cert = ddCovCert.SelectedValue;
int? x = (string.IsNullOrEmpty(cert)) ? null: int.Parse(cert);
Display(x);
How should I code this? The method takes a Nullable. If the dro...
Religious arguments aside, in C is ...
if (pointer[i] == NULL) ...
functionally equivalent to ...
if (!pointer[i]) ...
?
Does the later resolve quicker due to absence of a comparison ?
...
If I try a marshal a string that is really a NULL pointer, what will happen?
...