Link to home
Start Free TrialLog in
Avatar of 123456
123456Flag for Iran, Islamic Republic of

asked on

DBNAVIGATOR (enter data without enter ID for this data )

hi experts,
I have three tables
1-article(Aid,description,title,abstract,location); AID=P.K                                        relation:
2-keywordarticle( AID,keywordID) ; aid+keyword=p.k , aid=f.k,keywordID =f.k           article M:N   keyword
3-keyword(keywordID,keywordname);  keywordid:p.k

when a user enter  data as keywords in DBnavigator  don’t need to enter keywordID  only enter keywordname and
if keyword not exist in keyword table create a another keywordid dynamically and add this keywordid to keywordarticle table also.
If exist this keyword in the keyword table only add this keywordid to keywordarticle table.

Is this probable, if probable any one can help me in solving this problem?

Thanks in advance
Hamid reza.


Avatar of kretzschmar
kretzschmar
Flag of Germany image

usually use the beforepost-event
for check and supplying your id.

what database do you use and
what connectiontype (bde, ado, other)?

meikl ;-)
Avatar of 123456

ASKER

My database is access 2000
My adoconnection is ADO.
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
btw. if you leave your eMail,
then i could send you this sample project

meikl ;-)
Avatar of 123456

ASKER

thanks,  if probable
send this to hr_1357@yahoo.com
sample on the way ;-)
Avatar of 123456

ASKER

thanks i recieved your mail
please read the last of my comment in ( master-detail question)

your experience is so high in writing sql,
if you read the first comments of LUKA you found that his skill in writing sql is not so high(sorry i tell it).

thanks again.
hamid reza


Avatar of 123456

ASKER

Hi again meiki,
This section is not work properly , for it test a same word. I cant find it but why ?
//check if a Keyword is already assigned
function TForm1.KeyWordIDisNotAssigned(AArticleID, AKeyWordID : Integer) : Boolean;
begin
  result := not ADOTableKeyWordArticle.Locate('AID;KeyWordId',VarArrayOf([AArticleID,AKeyWordID]),[]);
end;



Avatar of 123456

ASKER

Hi again meiki,
This section is not work properly , for it test a same word. I cant find it but why ?
//check if a Keyword is already assigned
function TForm1.KeyWordIDisNotAssigned(AArticleID, AKeyWordID : Integer) : Boolean;
begin
  result := not ADOTableKeyWordArticle.Locate('AID;KeyWordId',VarArrayOf([AArticleID,AKeyWordID]),[]);
end;
Avatar of 123456

ASKER

Hi again meiki,
This section is not work properly , for it test a same word. I cant find it but why ?
//check if a Keyword is already assigned
function TForm1.KeyWordIDisNotAssigned(AArticleID, AKeyWordID : Integer) : Boolean;
begin
  result := not ADOTableKeyWordArticle.Locate('AID;KeyWordId',VarArrayOf([AArticleID,AKeyWordID]),[]);
end;
? what did not work properly

is there already the same keyword assigned to the article,
and its creates a new one or do it try to insert a new
relation, which already exists?

meikl ;-)
Avatar of 123456

ASKER

if you enter a same keyword that exist in special article dont work propely as you want.
and get error when insert to keywordarticle table with database.
because in my mind this if dont work properly:

if KeyWordIDisNotAssigned(ADOTableArticle.FieldByName('AID').AsInteger, KeyWordID) then
     
m.reza
not noticed this (works properly for me),
are you sure that you forward the right IDs?
Avatar of 123456

ASKER

please see my sql request in  master-detail question.
Avatar of 123456

ASKER

I enter in two times these words for a same article
Salam
But in second time get error with database not with your
raise Exception.Create('Keyword is already assigned to this Article!');
I don’t understand  because everything is right.
I test this program with step to step  I found that the result of this section in my computer every time is true .
For it get error with databases on second word.
//check if a Keyword is already assigned
function TForm1.KeyWordIDisNotAssigned(AArticleID, AKeyWordID : Integer) : Boolean;
begin
  result := not ADOTableKeyWordArticle.Locate('AID;KeyWordId',VarArrayOf([AArticleID,AKeyWordID]),[]);
end;

Why!?
 Say that my OS is win98A . and ado version is  2.7?
Avatar of 123456

ASKER

please save me meiki in (masetr-detail sql ) question.
well will try,
but i'm short in time.

does it have time until weekend?
(at weekend i'm not so under pressure,
so that i can look closer to this problem)

about the problem above,
there is another possibility to check,
if a keyword is assigned to an article
(i've heard, but this never happened to me,
that locate sometimes will not work properly)

solution follows later

meikl ;-)
Avatar of 123456

ASKER

I will see you as soon as possible for you.

i accept your answer and thanks for every assisting in this question and other questions.
GOD BLESS YOU.

hamid reza
Avatar of 123456

ASKER

any feed back from you, meikl?
Avatar of 123456

ASKER

any feed back from you meikl?

on thing:
about the problem of this question(locate problem).
i was found that if the key of seraching is increased to more than one key  this problem was occured.

See you as soon as probable.


God bless you
Hamid reza

well, a replacemant,

//check if a Keyword is already assigned
function TForm1.KeyWordIDisNotAssigned(AArticleID, AKeyWordID : Integer) : Boolean;
const vSQL = 'select * from KeywordArticle where AID = %d and KeyWordId = %d';
begin
  ADOQuery1.SQL.Text := Format(vSQL,[AArticleID,AKeyWordID]);
  ADOQuery1.Open;
  result := ADOQuery1.IsEmpty;
  ADOQuery1.Close;
end;

will be a bit slower than locate, but safer

hope this helps

meikl ;-)
Avatar of 123456

ASKER

Hi,
Great, the previous problem solved.

Every day I have a new problem !
You implement my request work with  dbgrid(that exist a lookup field for showing the related field in article table).
But ,The other changes such as delete and edit of keywords for a special article is unavailable(this unavailable for lookup field).
Do any work that add these features to  dbgrid or if adgrid have not these branch of features any other work existed for implementing  these features(ps: I cant use  express quantum grid  for its price although the copyright law is not attention in my country)?
My request :
I want to show the keywords for special article and change or delete keyword in this article but in m-n relationship
I cant, why?
I need m-n relationship.
Thanks in advance

God bless you
Hamid reza

Avatar of 123456

ASKER

any feed back from you
Avatar of 123456

ASKER

hi meikl,
i was solved my problem
thankd for your every assisting
hamid reza