Too few parameters.Expected

tirso

Active member
Joined
Nov 15, 2006
Messages
31
Programming Experience
1-3
Hi Lingsn, I'll change my code because the previous one it doesn't work. But still some errors found in my new code. Please help me. The error is in procedure "populate grid" highlight in red color and the message is "Too few parameters.Expected 1."

My new code

VB.NET:
    Private Sub btnFindDuplicates_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFindDuplicates.Click
        '/* Open database with fixed directory
        'objConnection = New OleDbConnection(strConnection)
        objConnection = New OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0;" & _
                        "Data Source =" & txtDirectory.Text & ";")
        Try
            objConnection.Open()
        Catch oleDbExceptionErr As OleDbException
            MessageBox.Show(oleDbExceptionErr.Message, "Open Access Database")
        Catch InvalidOperationExceptionErr As InvalidOperationException
            MessageBox.Show(InvalidOperationExceptionErr.Message, "Open Access Database")
        End Try
        'objCommand = New OleDbCommand("SELECT ID,Keycode,Chiban,Edaban from TableData where chiban" & _
        '    " In (select chiban from tabledata GROUP BY Chiban HAVING" & _
        '    " Count(*)>1) ORDER by chiban", objConnection)
        objCommand = New OleDbCommand("SELECT Chiban, count(*) AS Frequency from TableData where chiban" & _
            " In (select chiban from tabledata GROUP BY Chiban HAVING" & _
            " Count(*)>1) GROUP BY Chiban ORDER by chiban", objConnection)
        objCommand.CommandType = CommandType.TableDirect
        gbxListDuplicates.Text = "List of Duplicates"
        Call PopulateGrid()
        objCommand.Dispose()
        objCommand = Nothing
        objDataAdapter.Dispose()
        objDataAdapter = Nothing
        objDataTable.Dispose()
        objDataTable = Nothing
    End Sub

    Private Sub PopulateGrid()
        objDataAdapter = New OleDbDataAdapter
        objDataTable = New DataTable
        objDataAdapter.SelectCommand = objCommand
        Try
            [COLOR=red]objDataAdapter.Fill(objDataTable)[/COLOR]
            grdResult.DataSource = objDataTable
            grdResult.SelectionMode = DataGridViewSelectionMode.CellSelect
        Catch oledbException As Exception
            MessageBox.Show(oledbException.Message, "Access SQL")
        End Try
    End Sub

Tirso
 
What was the solution? Or should I consider this request withdrawn and delete the thread?
 
Back
Top