Hi, I need help with an if/then
I have some code pulling out the top line from a sql query (see below)
I would like to say... If there is a result i.e. a value is returnd then do this thing otherwise try something else.
I am not sure how to do the 'IF' bit, how do I say
'IF this query produces a result'
Thanks
I have some code pulling out the top line from a sql query (see below)
HTML:
Dim comd As SqlCommand = SqlConnection1.CreateCommand
comd.CommandType = CommandType.Text
comd.CommandText = "Select top 1 txtLeftAvgeMeanIMT,txtLeftAvgeMaxIMT,txtRightAvgeMeanIMT,txtRightAvgeMaxIMT from HACAROTIDSCAN WHERE DATEDIFF(day, datescandate, getdate()) =0 and patientid = '" & lblPatientID.Text & "'order by scanid desc"
SqlConnection1.Open()
Dim dr As SqlDataReader = comd.ExecuteReader
dr.Read()
txtLeftAvgeMeanIMT.Text = CStr(dr.GetValue(0))
txtLeftAvgeMaxIMT.Text = CStr(dr.GetValue(1))
txtRightAvgeMeanIMT.Text = CStr(dr.GetValue(2))
txtRightAvgeMaxIMT.Text = CStr(dr.GetValue(3))
I am not sure how to do the 'IF' bit, how do I say
'IF this query produces a result'
Thanks