I cannot find where the missing parameter is in my code that invokes the Try - Catch MessageBox Error in the Private Sub "PopulateGrid()". THe error message reads "Too few parameters. Expect 1." I have tried copy and pasting to eliminate the typo issue to no avail. THanks
[email protected]Imports System.Data
Imports System.Data.OleDb
Public Class Form1
'Form level variables
Private strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Documents and Settings\Marianne\Desktop\DBPTT\ProjectTimeTracker .mdb;"
Private objConnection As OleDbConnection
Private objCommand As OleDbCommand
Private objDataAdapter As OleDbDataAdapter
Private objDataSet As DataSet
Private Sub PopulateGrid()
'Initialize a new instance of the OleDbDataAdapter class
objDataAdapter = New OleDbDataAdapter
'Initialize a new instance of the DataSet class
objDataSet = New DataSet
'Set the SelectCommand for the OleDbDataAdapter
objDataAdapter.SelectCommand = objCommand
Try
'Populate the DataSet
objDataAdapter.Fill(objDataSet, "Projects")
'Bind the DataSet to the DataGrid
grdResults.DataSource = objDataSet
grdResults.DataMember = "Projects"
'Set the AlternatingRowsDefaultCellStyle.BackColor property
grdResults.AlternatingRowsDefaultCellStyle.BackCol or = Color.WhiteSmoke
'Set the CellBorderStyle property
grdResults.CellBorderStyle = DataGridViewCellBorderStyle.None
'Set the SelectionMode property
grdResults.SelectionMode = DataGridViewSelectionMode.FullRowSelect
'Set the AutoSizeColumnsMode property
grdResults.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
'Right align SequenceNumber column
grdResults.Columns("SequenceNumber").DefaultCellSt yle.Alignment = DataGridViewContentAlignment.MiddleRight
Catch OleDbException As OleDbException
MessageBox.Show(OleDbException.Message, "Access Queries")
End Try
'Cleanup
objCommand.Dispose()
objCommand = Nothing
objDataAdapter.Dispose()
objDataAdapter = Nothing
objDataSet.Dispose()
objDataSet = Nothing
objConnection.Dispose()
objConnection = Nothing
End Sub
Private Sub btnNonParameterQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNonParameterQuery.Click
'Initialize a new instance of the OleDbConnection class
objConnection = New OleDbConnection(strConnectionString)
'Initialize a new instance of the OleDbCommand class
objCommand = New OleDbCommand
'Set the objCommand object properties
objCommand.CommandText = "usp_SelectProjects"
objCommand.CommandType = CommandType.StoredProcedure
objCommand.Connection = objConnection
'Populate the DataGridView
Call PopulateGrid()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class