Solved

Record not found

Posted on 2006-06-08
1
231 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now