Solved

Record not found

Posted on 2006-06-08
1
236 Views
Last Modified: 2010-04-23
I am using Northwind database. How can I  display msgbox when the record is not found?


Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click

        Dim connectionString As String = "Data Source= SUPERMAN;Initial Catalog=Northwind;Integrated Security=True"
        Dim con As New SqlConnection(connectionString)
        Dim selectSQL As String = "select *from orders where orderid = '" & Me.ToolStripTextBox1.Text & "'"
        Dim da As New SqlDataAdapter(selectSQL, con)
        Dim ds As New DataSet


        If Me.ToolStripTextBox1.Text = Nothing Then
            MessageBox.Show("Please enter OrderId", "Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Information)



        Else


            da.Fill(ds, "orders")
            Me.DataGridView3.DataSource = ds.Tables("orders")

        End If

       

    End Sub
0
Comment
Question by:VBdotnet2005
1 Comment
 
LVL 10

Accepted Solution

by:
ericwong27 earned 250 total points
ID: 16867722

 If ds.Tables("orders").Rows.Count = 0 Then

     ' Do  something

 End If
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question