Hi,
hope someone has an answer to my problem.

my add and edit function is fully working.
but after a successful edit, another edit attempt has already an error.

Error: Procedure or Function has too many arguments specified

Private Sub global_edit()

        '- Is_with_ref_doc
        Dim ref_docCheckBox As Integer
        If Is_with_ref_docCheckBox.CheckState = CheckState.Checked Then
            ref_docCheckBox = 1
        Else
            ref_docCheckBox = 0
        End If

        '- Is_with_ref_doc
        Dim defCheckBox As Integer
        If Is_defCheckBox.CheckState = CheckState.Checked Then
            defCheckBox = 1
        Else
            defCheckBox = 0
        End If

        Dim i As Integer

        connectionString = conn_str()
        myConnection = New SqlClient.SqlConnection(connectionString)

        Try
            myConnection.Open()
        Catch ex As Exception
            MessageBox.Show("error:" + ex.Message)
        End Try

        sqlStatement.CommandType = CommandType.StoredProcedure
        sqlStatement.Connection = myConnection

        sqlStatement.CommandText = "update_pr_type"
        sqlStatement.Parameters.AddWithValue("@Description", Trim(DescriptionTextBox.Text))
        sqlStatement.Parameters.AddWithValue("@ref_doc", ref_docCheckBox)
        sqlStatement.Parameters.AddWithValue("@refdocdesc", Trim(RefdocdescTextBox.Text))
        sqlStatement.Parameters.AddWithValue("@def", defCheckBox)
        sqlStatement.Parameters.AddWithValue("@gl_seg_acct", Trim(Gl_seg_acctTextBox.Text))
        sqlStatement.Parameters.AddWithValue("@id", Pr_typeDataGridView.Item(0, i).Value)

        Try
            sqlStatement.ExecuteScalar()
            ClearTextBox(GroupBox1)
            DescriptionTextBox.Focus()
            MessageBox.Show("Update entry", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            MessageBox.Show("Error: " + ex.Message)
        End Try

        myConnection.Close()

    End Sub

tia (thanks in advance)

Recommended Answers

All 2 Replies

I will suggest to insert

sqlStatement = New SqlCommand()

before

sqlStatement.CommandType = CommandType.StoredProcedure

This will empty the previous contents if any.

Hope this helps

I will suggest to insert

sqlStatement = New SqlCommand()

before

sqlStatement.CommandType = CommandType.StoredProcedure

This will empty the previous contents if any.

Hope this helps

Thank you lola, ive been searching all day for the solution (shame on me),
and i find it only here.

works like a charm.

thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.