[RESOLVED] searching a database for enteries with blank dates
hello
i need to populate my datagrid view with records from my database.
the records i require are the ones that have not yet been closed so i wish to search for all records where there is no date in the closed column.
im not sure how to write my sql, i tried.....
select * from table where closed = ""
i just get a syntax error
i looked on the net but couldnt find any examples of searching by a blank date!
Thanks,
Iain
Re: searching a database for enteries with blank dates
"Blank" values are commonly said to be NULL:
Code:
SELECT * FROM MyTable WHERE MyColumn IS NULL
Note that this is actually an SQL question and belongs in the Database Development forum. It has no specific connection to VB.NET.
Re: searching a database for enteries with blank dates
ah brilliant!!
thanks alot!
i tried db.null and got no where with that, didnt even occur to me to just use null!
cheers!
Re: [RESOLVED] searching a database for enteries with blank dates
DBNull is a .NET type. It's nothing to do with SQL. If you assign DBNull.Value to a parameter or field in VB code then that becomes NULL when inserted into the SQL, e.g.
vb.net Code:
Dim command As New SqlCommand("SELECT * FROM MyTable WHERE MyColumn IS @MyColumn", connection)
command.Parameter.Add("@MyColumn", SqlDbType.VarChar, 50).Value = DBNull.Value