Results 1 to 3 of 3

Thread: Checking for records before trying to fill datagrid

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354

    Checking for records before trying to fill datagrid

    I want to check for matching records in my table before I try to fill the datagrid. Basicaly I don't want to open up a blank grid. How can I do this? Here is my String:
    VB Code:
    1. Try
    2.     Dim Data_Adapter As SqlDataAdapter
    3.         Data_Adapter = New SqlDataAdapter("Select " & _
    4.         "Job," & _
    5.         "Employee," & _
    6.         "Phase," & _
    7.         "PostDate," & _
    8.         "Rate," & _
    9.         "Hours," & _
    10.         "Amt," & _
    11.         "EarnCode," & _
    12.         "InsCode," & _
    13.         "PRDept, " & _
    14.         "BatchSeq " & _
    15.         "From aTable Where Employee='" & _
    16.         (strEmp) & "' " & "Order by BatchSeq DESC", strCONN)
    17.        
    18.     Data_Adapter.TableMappings.Add("Table", "Stuff")
    19.     m_DataSet = New DataSet
    20.         Data_Adapter.Fill(m_DataSet)
    21.     DataGrid3.DataSource = m_DataSet.Tables("Stuff")

  2. #2
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    Something like:
    VB Code:
    1. If m_DataSet.Tables("Stuff").Rows.Count() > 0 Then
    2.  DataGrid3.DataSource = m_DataSet.Tables("Stuff")
    3. End If

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354
    That worked perfectly. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width