Results 1 to 2 of 2

Thread: [SOLVED] Query not working with DataGridView control in VB 2010 Express

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    [SOLVED] Query not working with DataGridView control in VB 2010 Express

    I am trying to learn different ways to load a DataGridView control.

    This code below works just fine:

    Working Code:
    1. '**** Fill DGV with desired Managers
    2.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    3.         DataGridView1.Visible = True
    4.  
    5.         Dim FoundIndex As Integer = ManagersTableBindingSource.Find("Mgr-LN", TextBox1.Text)
    6.         If FoundIndex > -1 Then    ' see if Manager found
    7.  
    8.             '**** just examples of how to get these values  -  not needed for this Click event
    9.             Dim RowNum As Integer = DataGridView1.CurrentRow.Index   ' index is 0 based
    10.             txtRowNum.Text = RowNum.ToString()
    11.             '****
    12.  
    13.             '**** This causes the DGV to fill with all Managers with a LN equal to TextBox1.Text
    14.             ManagersTableBindingSource.Filter = "[Mgr-LN] = '" & TextBox1.Text & "'"
    15.             '****
    16.         Else
    17.             MsgBox("Manager not found")
    18.             TextBox1.Text = ""
    19.         End If
    20.     End Sub

    The Query below placed in the DGV control or in the TableAdaptor don't work. A blank DGB is returned. What is wrong??

    NonWorking Query Code:
    1. SELECT        [Mgr-NameLNFN], [Mgr-FN], [Mgr-LN], [Mgr-Title], [Mgr-StartDte], [Mgr-TermDate], [Mgr-NumSP], [Mgr-Password], [Mgr-FNLN], [Mgr-KntDailySpFU],
    2.                          [Mgr-KntWeeklySpFU], [Mgr-EmailLogonName], [Mgr-EmailLogonPW], [Mgr-EmailAddr], [Mgr-CurYrGoalM1], [Mgr-CurYrGoalM2], [Mgr-CurYrGoalM3],
    3.                          [Mgr-CurYrGoalM4], [Mgr-CurYrGoalM5], [Mgr-CurYrGoalM6], [Mgr-CurYrGoalM7], [Mgr-CurYrGoalM8], [Mgr-CurYrGoalM9], [Mgr-CurYrGoalM10], [Mgr-CurYrGoalM11],
    4.                          [Mgr-CurYrGoalM12], [Mgr-CurYrUnitsM1], [Mgr-CurYrUnitsM2], [Mgr-CurYrUnitsM3], [Mgr-CurYrUnitsM4], [Mgr-CurYrUnitsM5], [Mgr-CurYrUnitsM6],
    5.                          [Mgr-CurYrUnitsM7], [Mgr-CurYrUnitsM8], [Mgr-CurYrUnitsM9], [Mgr-CurYrUnitsM10], [Mgr-CurYrUnitsM11], [Mgr-CurYrUnitsM12], [Mgr-PrevYrUnitsM1],
    6.                          [Mgr-PrevYrUnitsM2], [Mgr-PrevYrUnitsM3], [Mgr-PrevYrUnitsM4], [Mgr-PrevYrUnitsM5], [Mgr-PrevYrUnitsM6], [Mgr-PrevYrUnitsM7], [Mgr-PrevYrUnitsM8],
    7.                          [Mgr-PrevYrUnitsM9], [Mgr-PrevYrUnitsM10], [Mgr-PrevYrUnitsM11], [Mgr-PrevYrUnitsM12], [Mgr-NumKey]
    8. FROM            ManagersTable
    9. WHERE        ([Mgr-LN] = '" & searchln & "')
    Last edited by DexterRose; May 11th, 2013 at 03:56 PM.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: [Solved] Query not working with DataGridView control in VB 2010 Express

    Cancel this post. I just found the solution. I deleted the auto generated "ToolStrip" from my form and everything worked just fine!!

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