Solved

deleteing a selected name from a database?

Posted on 2006-10-30
6
223 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 32 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now