Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

deleteing a selected name from a database?

Posted on 2006-10-30
6
Medium Priority
?
231 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 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

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

705 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