troubleshooting Question

ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 6.

Avatar of dhireshinfotronicsindia
dhireshinfotronicsindia asked on
Microsoft Access
2 Comments1 Solution4685 ViewsLast Modified:
Hello

below is my code and i get error as
1.) ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 6. on Update
2.) ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. on delete

Can i get help on this cause
______________________________________________________________________________________
Imports System.Data.Odbc
Partial Class charges
    Inherits System.Web.UI.Page
    Dim conn As New OdbcConnection("dsn=tracking")
    Dim command As New OdbcCommand
    Public come_from As String
    Public ch_id As Integer

    Protected Sub grdview_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdview.SelectedIndexChanged
        ch_id = grdview.SelectedRow.Cells(1).Text
        command = New OdbcCommand("select * from tbl_charges where charges_id=" & ch_id & "", conn)
        Dim drreader As OdbcDataReader
        drreader = command.ExecuteReader
        If drreader.Read Then
            txtcode.Text = drreader("charges_code")
            txtcurrency.Text = drreader("currency")
            txtdescription.Text = drreader("description")
           
            If drreader("service_yes") = True Then
                rdyes.Checked = True
                rdno.Checked = False
            ElseIf drreader("service_no") = True Then
                rdno.Checked = True
                rdyes.Checked = False
            End If
        End If
        drreader.Close()
    End Sub

    Protected Sub cmdadd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdadd.Click
        txtcode.Text = " "
        txtdescription.Text = " "
        txtcurrency.Text = " "

        txtcode.Enabled = True
        txtdescription.Enabled = True
        txtcurrency.Enabled = True
        cmdadd.Enabled = False
        cmdedit.Enabled = False
        cmdsave.Enabled = True
        cmddelete.Enabled = False
        come_from = "add"
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        txtcode.Enabled = False
        txtdescription.Enabled = False
        txtcurrency.Enabled = False
        cmdadd.Enabled = True
        cmdedit.Enabled = True
        cmdsave.Enabled = False
        cmddelete.Enabled = True
        conn.Open()
    End Sub

    Protected Sub cmdsave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdsave.Click

        Dim adp As New OdbcCommand("SELECT charges_code FROM [tbl_charges] where charges_code='" & txtcode.Text & "'", conn)
        Dim ds1 As OdbcDataReader

        ds1 = adp.ExecuteReader
        If ds1.Read Then
            Label1.Text = "Category Already Exists, Kindly Enter Unique Category Name"
        Else
            Dim command As New OdbcCommand("insert into tbl_charges ([charges_code],[description],[currency],[service_yes],[service_no])values('" & txtcode.Text.Trim & "','" & txtdescription.Text.Trim & "','" & txtcurrency.Text.Trim & "'," & rdyes.Checked & "," & rdno.Checked & ")", conn)
            command.ExecuteNonQuery()

        End If
    End Sub

    Protected Sub cmdedit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdedit.Click
        If cmdedit.Text = "EDIT" Then
            cmdadd.Enabled = False
            cmddelete.Enabled = False
            txtcode.Enabled = True
            txtdescription.Enabled = True
            txtcurrency.Enabled = True
            rdyes.Enabled = True
            rdno.Enabled = True
            cmdedit.Text = "UPADTE"
            come_from = "edit"
        Else
            command = New OdbcCommand("Update tbl_branch set charges_code='" & txtcode.Text.Trim & "',[description]='" & txtdescription.Text.Trim & "', [currency]='" & txtcurrency.Text & "',service_yes=" & rdyes.Checked & ",service_no=" & rdno.Checked & " where charges_id=" & grdview.SelectedRow.Cells(1).Text & "", conn)
            command.ExecuteNonQuery()
            cmdedit.Text = "EDIT"
            cmdadd.Enabled = True
            cmdedit.Enabled = True
            cmdsave.Enabled = False
            cmddelete.Enabled = True
            grdview.DataBind()
            'command = New OdbcCommand("Update tbl_charges set charges_code='" & txtcode.Text.Trim & "',[description]='" & txtdescription.Text.Trim & "',[currency[='" & txtcurrency.Text & "', service_yes=" & rdyes.Checked & ",service_no=" & rdno.Checked & " where charges_id=" & grdview.SelectedRow.Cells(1).Text & "", conn)
        End If
    End Sub

    Protected Sub cmddelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmddelete.Click
        command = New OdbcCommand("delete * from tbl_charges where category_id=" & grdview.SelectedRow.Cells(1).Text & "", conn)
        command.ExecuteNonQuery()
    End Sub

    Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
        conn.Close()
    End Sub
End Class

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros