I am using the following code...

vb Code:
  1. Public Function getdatafi(ByVal querystring As String)
  2.         'MsgBox(querystring)
  3.         Using connection As New SqlConnection(GetConnectionStringfi)
  4.             Dim command As New SqlCommand(querystring, connection)
  5.             connection.Open()
  6.  
  7.             Dim reader As SqlDataReader = command.ExecuteReader
  8.  
  9.             While reader.Read
  10.                 Return reader.GetValue(0)
  11.             End While
  12.  
  13.             reader.Close()
  14.  
  15.         End Using
  16.  
  17.     End Function

vb Code:
  1. tempdimid = getdatafi("SELECT dim_id from dim_info where inspection_id = " & inspectionid & _
  2.             " and dim_name = '" & dimname(tempnumber) & "'")

I put a break in and viewed the sql code. It is the correct code but it returns 0. If I run the exact sql code that the program creates in the SQL query anylizer, it returns the correct number. I am using the getdatafi function in other places and it works as it should. Does anyone know why this is not working?