Solved

deleteing a selected name from a database?

Posted on 2006-10-30
6
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 19

Accepted Solution

by:
MerijnB earned 32 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 31 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 31 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 31 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

623 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