VB .NET SQL issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jawad

    #1

    VB .NET SQL issue

    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!

  • Jawad

    #2
    Re: VB .NET SQL issue

    Here is VB .NET code...

    Dim conn As New System.Data.Sql Client.SqlConne ction(ConString )
    Dim cmd As New System.Data.Sql Client.SqlComma nd(SQL, conn)
    Dim reader As System.Data.Sql Client.SqlDataR eader

    Try
    conn.Open()
    reader = cmd.ExecuteRead er()
    While reader.Read()
    'Response.Write ("DATA -" & reader(0) & "<br")
    End While
    reader.Close()
    Finally
    conn.Close()
    End Try

    Comment

    • Jawad

      #3
      Re: VB .NET SQL issue

      akhhhhhh....aft er 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!

      Comment

      Working...