Attempting to Use SELECT statements instead of query builder

Hello all I’m attempting to hardcode my queries but I am unable to get my results to populate my datagrid properly…well at all actually. Can anyone tell me what I’m doing wrong? Public Class Form1

Private Access As New DBControl Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click Me.Close() End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load Access.ExecQuery("SELECT * FROM Master ORDER BY Department ASC") 'Fills Data Table from Master Table and sorts by Department in Ascending order If Not String.IsNullOrEmpty(Access.Exception) Then MsgBox(Access.Exception) : Exit Sub 'if there is an error detected let us know 'FILL DATAGRID dgvBooks.DataSource = Access.DBDT 'FILL DEPARTMENT COMBOBOX METHOD 1 CODE: For Each R As DataRow In Access.DBDT.Rows deptBox.Items.Add(R("Department")) Next 'FILL COURSE COMBOBOX For Each R As DataRow In Access.DBDT.Rows courseBox.Items.Add(R("Course")) Next 'FILL SECTION COMBOBOX METHOD 2: ' DATA BIND THE SECTION TABLE TO THE SECTION COMBOBOX 'TODO: This line of code loads data into the 'BookListDataSet.Section' table. You can move, or remove it, as needed. Me.SectionTableAdapter.Fill(Me.BookListDataSet.Section) End Sub Private Sub SearchISBN(ISBN As String) 'ADD PARAMATERS & RUN QUERY Access.AddParam("@ISBN", "%" & ISBN & "%") Access.ExecQuery("SELECT * FROM Master WHERE ISBN LIKE @ISBN") 'FILL DATAGRID WITH ISBN WILDCARD RESULTS dgvBooks.DataSource = Access.DBDT End Sub Private Sub ISBNButton_Click(sender As Object, e As EventArgs) Handles ISBNButton.Click SearchISBN(ISBNTextBox.Text) End Sub Private Sub semesterButton_Click(sender As Object, e As EventArgs) Handles semesterButton.Click If rbFall1.Checked = True Then Access.ExecQuery("SELECT * FROM Master WHERE Semester = 'Fall' AND [Year Taken] = 1") dgvBooks.DataSource = Access.DBDT ElseIf rbSpring1.Checked Then Access.ExecQuery("SELECT * FROM Master WHERE Semester = 'Spring' AND [Year Taken] = 1") dgvBooks.DataSource = Access.DBDT ElseIf rbSummer.Checked Then Access.ExecQuery("SELECT * FROM Master WHERE Semester = 'Summer' AND [Year Taken] = 1") dgvBooks.DataSource = Access.DBDT ElseIf rbFall2.Checked Then Access.ExecQuery("SELECT * FROM Master WHERE Semester = 'Fall' AND [Year Taken] = 2") dgvBooks.DataSource = Access.DBDT ElseIf rbSpring2.Checked Then Access.ExecQuery("SELECT * FROM Master WHERE Semester = 'Spring' AND [Year Taken] = 2") dgvBooks.DataSource = Access.DBDT End If End Sub 

End Class

submitted by /u/bbean_16
[link] [comments]

Leave a Reply