Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete a row from datagrid without datakeyfield? 1

Status
Not open for further replies.

ietprofessional

Programmer
Apr 1, 2004
267
US
Hi Everyone,

I have multiple forms and a datagrid on each one. The last form will take all the data from the previous forms, which I saved in a dataset with multiple datatables, and save it to a database.

My problem is I have a form that has 5 fields, none of the fields are required. I save the data entered into these fields in a dataset and display the dataset in a datagrid. I want to allow the users to delete items from the datagrid/dataset but I don't have a primary key, because I don't have any required or unique values in the dataset.

How can I delete items from the datagrid/dataset without a datakeyfield?

Thanks!
 
A better and more philosophical question:

How can you (or rather, WHY would you) delete anything from anywhere w/o a primary key?

-paul

penny.gif
penny.gif

The answer to getting answered -- faq855-2992
 
Link9 there has to be a solution to this problem. A condescending approach to this question won't help me or anyone else that might have this same problem in the future.

Please help if you have any ideas to solve this problem.

Thanks!





 
ietprofessional - link9 has a valid point. Rather than look on his question as being condesending look at it as being helpful.

If there was a primary key then there wouldn't be a problem...

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
The tables that will receive the data have autonumber primary keys. The point of the question is I'm putting data in a dataset until the final submission button is clicked.

I need to be able to delete rows of data from a datagrid before it is placed into a database. Once the data is in the database the data will have a primary key.


 
That doesn't stop you from creating each row with a primary key - simply create one so you can do your update/insert/delete on your datagrid, but don't insert it into the database.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
ca8msm is right. You need to add an PK to that table.
Set its
AutoIncrement property to True
AutoIncrementSeed to -1 or 1
AutoIncrementStep to -1 or 1
I like the negative numbers so that I know it didn't come from the DB

That way you have a primary key.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top