Need help Delete Record from Access DataBase

wiccan2

New member
Joined
Dec 11, 2006
Messages
2
Programming Experience
Beginner
Hi I'm haveing some trouble with my VB.net coursework for college.

I can get every thing working exept for my delete button i keep getting an error every time i click it.

VB.NET:
Dim row As Integer
row = LoginBindingSource.Position
LoginDataSet.login.Rows(row).Delete()
Me.LoginBindingSource.EndEdit()
Me.LoginTableAdapter.Update(Me.LoginDataSet.login) 'Update requires a valid DeleteCommand when passed DataRow collection with deleted rows.
Me.LoginDataSet.AcceptChanges()

the comment is the error and it is next to the line that visual studios highlights

i need this desperatly because my coursework has to be in after christmas

any help is apreciated
 
Your table adapter (LoginTableAdapter) is missing a valid DeleteCommand, which should have been automatically generated by Visual Studio.

Try the following:
  1. Open up the .xsd file that holds the dataset. It's in the "Solution Explorer" window.
  2. Click the "Table Adapter" part of the Login table.
  3. Is there a query present for DeleteCommand, InsertCommand, SelectCommand, and UpdateCommand? If not, right-click the Table Adapter and choose "Configure...". Go through the wizard and it will re-generate the queries.
If it still won't automatically generate the DeleteCommand query, check your table's syntax. There should be a primary key in there somewhere.
 
Hi, I fixed this now.

The problem was what you said the table had no primary key which was preventing the table adapter from generating the commands.

Thanks any way though.
 
Back
Top