I have the following form and I'm trying to add a error to the page that if the recordset = 0 then there is a message on the web page stating that there were no results. What's the best way to do that?
Code:
Imports System.Data.SqlClient Imports System.Data Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load TimeDateLabel.Text = String.Format("Today's date is {0:F}", DateTime.Now) End Sub Protected Sub whosoncallButton_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles whosoncallButton.Click Dim dt As New DataTable Dim da As New SqlDataAdapter Dim cmd As New SqlCommand Dim connectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx" Dim con As New SqlConnection(connectionString) con.Open() cmd.Connection = con cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = "sp_getoncallresults" cmd.Parameters.AddWithValue("@schedname", schednameTextBox.Text) cmd.Parameters.AddWithValue("@sincedate", sincedateTextBox.Text) Try da.SelectCommand = cmd da.Fill(dt) GridView1.DataSource = dt GridView1.DataBind() con.Dispose() Catch ex As Exception Response.Write("Error:" & ex.ToString) End Try End Sub Protected Sub clearButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles clearButton.Click schednameTextBox.Text = "" sincedateTextBox.Text = "" GridView1.DataSource = Nothing GridView1.DataBind() End Sub End Class
Comment