Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27248

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

$
0
0
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 & "')

Viewing all articles
Browse latest Browse all 27248


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>