Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

deleteing a selected name from a database?

Posted on 2006-10-30
6
Medium Priority
?
232 Views
Last Modified: 2011-09-20
I added a new database to hold blocked members on my site I have it adding fine but the problem I have is when I goto delete the user from the blocked database is removes the person that blocked the other persons account

can sumone show me were am going worng on the delete part of my code thanks alot :)

[code]
//=============================================================
//oooooooooooooooooooooooooo ADD BLOCKED USER oooooooooooooooooooooooooooooooooo
//=============================================================

if (com='RAddBUser') then
    begin
    if AccountTable.Locate('Name',DM.UserName,[]) then
     begin
      AccountTable.Edit;
      AccountTable.FieldByName('BDU').AsString:=dat[5]; // adds nick to database
      AccountTable.Post;
      showmessage('User '+dat[1]+' Added OK');
   end;
end;

//=============================================================
//oooooooooooooooooooooooooo REMOVE BLOCKED USER ooooooooooooooooooooooooooooooo
//=============================================================

if (com='RDelBList') then
   if dat[0]<>'' then
   begin
   if AccountTable.Locate('Name',DM.UserName,[]) then
   begin
      AccountTable.Delete; // removed nick from database      
     showmessage('User '+dat[1]+' Deleted OK');
  end;
end;
0
Comment
Question by:fiveuk
6 Comments
 
LVL 19

Accepted Solution

by:
MerijnB earned 128 total points
ID: 17832665
You are deleting the whole record, shouldn't you just clear the BDU field?

if (com='RDelBList') then
   if dat[0]<>'' then
   begin
   if AccountTable.Locate('Name',DM.UserName,[]) then
   begin
      AccountTable.FieldByName('BDU').AsString:=''; // removed nick from database
     showmessage('User '+dat[1]+' Deleted OK');
  end;
end;
0
 
LVL 15

Assisted Solution

by:mikelittlewood
mikelittlewood earned 124 total points
ID: 17832848
or if you mean to delete the record from the database, shouldnt you be looking for BDU instead?

if (com='RDelBList') then
   if dat[0]<>'' then
   begin
   if AccountTable.Locate('BDU', dat[5], []) then
   begin
      AccountTable.Delete; // removed nick from database
     showmessage('User '+dat[1]+' Deleted OK');
  end;

0
 
LVL 9

Assisted Solution

by:sun4sunday
sun4sunday earned 124 total points
ID: 17832896
In generally, May be instead of creating another table for blocking the users, it can be done on the same user table setting a flag for the Blocked users. I am not sure it will fit in your requirements.
No need to add the user in another table, delete again. For the administrator it can be done through a radio button.

It is just a suggestion.

sun4sunday
0
 
LVL 11

Assisted Solution

by:calinutz
calinutz earned 124 total points
ID: 17840593
Make sure that inside your database you did not set some foreign constraints between the tables with cascade deletion checked.
You probabely made a constraint like this between the identification of user that blocks  from the table of blocked users and the second part of the constraint is probabely in the table that holds the users.

So re-check your tables, because it might have nothing to do with your delphi code.
(Also I suggest that you should use UPDATE, INSERT, SELECT instead of working with tables, gives you a much cleaner code - in my opinion)

Regards
:-)
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21133088
Forced accept.

Computer101
EE Admin
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month12 days, 23 hours left to enroll

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question