VB .NET SQL issue

  • Thread starter Thread starter Jawad
  • Start date Start date
J

Jawad

I cant seem to figure out why my full outer join query works fine in
Query Analyzer but its not returning all the data when i read the data
back from reader.

QUERY:
-------------

SELECT *
FROM (
(SELECT col1, col2 FROM table1 WHERE col1 LIKE
'STRING1') t1
FULL OUTER JOIN
(SELECT col1, col2 FROM table1 WHERE col1 LIKE
'STRING'2) t2
ON (t1.col1 = t2.col1)
)
WHERE t1.col1 = NULL
OR t2.col1 = NULL
OR t1.col2 <> t2.col2

Query Analyzer Result :
==================

COL1 COL2 COL1 COL2
NULL NULL data1 data2
data3 data4 NULL NULL

This looks great..but when i try to run this query in my code, nothing
comes back.
I tried using different queries...and they all seem to work as long as
there is no NULL involved.
Any one have any idea whats going on?? Thanks!
 
Here is VB .NET code...

Dim conn As New System.Data.SqlClient.SqlConnection(ConString)
Dim cmd As New System.Data.SqlClient.SqlCommand(SQL, conn)
Dim reader As System.Data.SqlClient.SqlDataReader

Try
conn.Open()
reader = cmd.ExecuteReader()
While reader.Read()
'Response.Write("DATA -> " & reader(0) & "<br> ")
End While
reader.Close()
Finally
conn.Close()
End Try
 
akhhhhhh....after couple of hours of trying to figure this out i
finally figured it out.

in VB .net i cant use "WHERE COL1 = NULL" i had to change this to
"WHERE COL1 IS NULL" and i got all the results back the way i wanted
to. Stupid Mistake!
 
Back
Top