Solved

deleteing a selected name from a database?

Posted on 2006-10-30
6
227 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

828 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