Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET Database and Reporting (http://www.xtremevbtalk.com/-net-database-and-reporting/)
-   -   Delete record using code (http://www.xtremevbtalk.com/-net-database-and-reporting/327607-delete-record-using-code.html)

VPL 05-07-2015 09:12 PM

Delete record using code
 
I am new to vb.net and started learning it for the last two weeks.

I created one table in Access with following fields

a. Request ID
b. Person Name
c. Request Date
d. Customer Type (New or already existing)
e. Customer Code
f. Customer Name

I tried to delete a record with following code
Code:

Private Sub Form2_Load(sender As Object, e As EventArgs) Handles Me.Load
        dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
        dbSource = "Data Source = E:\sample-status\ggoe.mdb"
        con.ConnectionString = dbProvider & dbSource
        con.Open()
        sql = "SELECT * FROM samplerequest"
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "ggoe")
        'con.Close()
        MaxRows = ds.Tables("ggoe").Rows.Count
End Sub
==========================================

Private Sub Delete_Click(sender As Object, e As EventArgs) Handles Delete.Click
        inc = 0
        For inc = 0 To MaxRows
                If Val(RequestNo.Text) = inc Then
        inc = inc - 1
                Dim cb As New OleDb.OleDbCommandBuilder(da)
If MessageBox.Show("Do you really want to Delete this Record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then
        MsgBox("Operation Cancelled")
        Exit Sub
        End If
        ds.Tables("ggoe").Rows(inc).Delete()
                MaxRows = MaxRows - 1
        da.Update(ds, "ggoe")
                Exit Sub
        End If
        Next inc
    End Sub
==================================

I got error message "One of the parameter is missing"

Please help me to correct this error.


All times are GMT -6. The time now is 10:23 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.