Based on mbanavige's feedback I have made an adjustment to the code I had earlier posted:
Get the connection string, In this case it's comming from the web.config file
Dim strCon As String = System.Configuration.ConfigurationManager.ConnectionStrings("con").ConnectionString
Dim con As New SqlConnection(strCon)
dim sSQL as string
If type = "basic" then
sSQL = "EXEC basicSearch " & txtSearch.Text
else
sSQL = "EXEC advancedSearch " & txtTitle.Text & "," & ddlStatus.SelectedValue ... and so on.
end if
dim cmd as new SqlCommand(sSQL, con)
cmd.CommandType = Data.CommandType.StoredProcedure
'Setting the dataAdapter to the sqlCommand.
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
Try
con.open()
da.Fill(ds)
Catch ex As Exception
Finally
con.Close()
End Try
'Setting the dataSource of the grid here.
grdView.DataSource = ds.Tables(0)
grdView.AutoGenerateColumns = true
grdView.dataBind()
Much cleaner! Thanks again.