Something like this should work:
Code:
Dim yourConnectionString As String = <whatever your connection string is>
Dim retVal As Integer
Using cn As New SqlClient.SqlConnection(yourConnectionString)
Using cmd As SqlClient.SqlCommand = cn.CreateCommand
Try
cn.Open
cmd.CommandText = "select max(SEQUENCE) as MYSEQ from Order where ordernumber ='20140710'"
Dim obj As Object = cmd.ExecuteScalar
If obj Isnot Nothing then
retVal = CInt(obj)
Else
'There were no records, so what do you want to do?
End If
Catch ex As Exception
'Do what you want. The most likely exception is that the DB is unavailable.
End Try
End Using
End Using
Return retVal