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

x
?
Solved

ado query

Posted on 2002-04-10
20
Medium Priority
?
362 Views
Last Modified: 2013-11-23
I use two ado query in my form.the first is for querying.the next is for insert.the query component is linked to a datagrid component.
when I push the new button,I use the second ado query to execsql to insert an empty record.I set some default value to it.and then I close and open(also try the requery) the first ado query.but the data displayed in datagrid is still not having the new record.
does anyone can help me?
0
Comment
Question by:tzxie2000
[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
  • 13
  • 5
  • 2
20 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6933246
can you show the queries and your code?
0
 
LVL 5

Author Comment

by:tzxie2000
ID: 6933256

  with qryExec do
  begin
    Close;
    sql.Clear;
    NodeType := GetNodeType(TVAll.Selected);
    if (NodeType=NodeTypeGroupUP) then
    begin
      GroupINfo := TVAll.Selected.Data;

      sql.Add(Format('insert into RuleList(GroupID,UserID,SoftID,ModelID) values(%d,0,0,0)',[GroupInfo.GroupID]));
    end;
    if (NodeType=NodeTypeUserUP) then
    begin
      UserINfo := TVAll.Selected.Data;
      sql.Add(Format('insert into RuleList(GroupID,UserID,SoftID,ModelID) values(0,%d,0,0)',[UserInfo.UserID]));
    end;
    ExecSql;
    Close;
  end;
  with qryGroupRule do
  begin
    Close;
    Open;
    Requery;
  end;
0
 
LVL 5

Author Comment

by:tzxie2000
ID: 6933259
the sql in qryGroupRule

 if (TSRuleGroupInfo = PCInfo.Pages[PCInfo.ActivePageIndex]) then
  begin
    NodeType := GetNodeType(TVAll.Selected);
    with qryGroupRule do
    begin
      Close;
      sql.Clear;
      if (NodeType = NodeTypeGroupUP) then
      begin
        GroupInfo := TVAll.Selected.Data;
        Sql.Add('Select RuleList.* ,SoftList.SoftName as SN,'''' as MN from RuleList ,SoftList ');
        sql.Add(Format('where (RuleList.SoftID<>0) and (RuleList.SoftID=SoftList.SoftID) and  (GroupID = %d) ',[GroupInfo.GroupID]));
        sql.Add('union');
        Sql.Add('select RuleList.*,'''' as SN,ModelList.ModelName as MN from RuleList ,ModelList ');
        sql.Add(Format('where (RuleList.ModelID<>0) and (RuleList.ModelID=ModelList.ModelID) and (GroupID = %d)',[GroupInfo.GroupID]));
        sql.Add('union');
        Sql.Add('select RuleList.*,'''' as SN,'''' as MN from RuleList');
        sql.Add(Format('where (RuleList.SoftID=0) and (RuleList.ModelID=0) and (GroupID = %d)',[GroupInfo.GroupID]));
        sql.Add(' Order by RuleID');
{        Sql.Add('Select RuleList.* ,SoftList.SoftName as SN,'''' as MN from RuleList left join SoftList ');
        sql.Add(Format('on RuleList.SoftID=SoftList.SoftID where (GroupID = %d)',[GroupInfo.GroupID]));
        sql.Add('union');
        Sql.Add('select RuleList.*,'''' as SN,ModelList.ModelName as MN from RuleList left join ModelList ');
        sql.Add(Format('on (RuleList.ModelID=ModelList.ModelID) where (GroupID = %d)',[GroupInfo.GroupID]));
        sql.Add(' Order by RuleID');}
      end;
      if (NodeType = NodeTypeUserUp) then
      begin
        UserInfo := TVAll.Selected.Data;
        Sql.Add('Select RuleList.* ,SoftList.SoftName as SN,'''' as MN left join RuleList,SoftList ');
        sql.Add(Format('on (RuleList.SoftID=SoftList.SoftID) and (UserID = %d)',[UserInfo.UserID]));
        sql.Add('union');
        Sql.Add('select RuleList.*,'''' as SN,ModelList.ModelName as MN left join RuleList,ModelList ');
        sql.Add(Format('on (RuleList.ModelID=ModelList.ModelID) and (UserID = %d)',[UserInfo.UserID]));
        sql.Add(' Order by RuleID');
      end;
      Open;
      First;
    end;
    CBGroupExtend.OnClick(Nil);
  end;
0
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!

 
LVL 5

Author Comment

by:tzxie2000
ID: 6933297
the sql in qryGroupRule

 if (TSRuleGroupInfo = PCInfo.Pages[PCInfo.ActivePageIndex]) then
  begin
    NodeType := GetNodeType(TVAll.Selected);
    with qryGroupRule do
    begin
      Close;
      sql.Clear;
      if (NodeType = NodeTypeGroupUP) then
      begin
        GroupInfo := TVAll.Selected.Data;
        Sql.Add('Select RuleList.* ,SoftList.SoftName as SN,'''' as MN from RuleList ,SoftList ');
        sql.Add(Format('where (RuleList.SoftID<>0) and (RuleList.SoftID=SoftList.SoftID) and  (GroupID = %d) ',[GroupInfo.GroupID]));
        sql.Add('union');
        Sql.Add('select RuleList.*,'''' as SN,ModelList.ModelName as MN from RuleList ,ModelList ');
        sql.Add(Format('where (RuleList.ModelID<>0) and (RuleList.ModelID=ModelList.ModelID) and (GroupID = %d)',[GroupInfo.GroupID]));
        sql.Add('union');
        Sql.Add('select RuleList.*,'''' as SN,'''' as MN from RuleList');
        sql.Add(Format('where (RuleList.SoftID=0) and (RuleList.ModelID=0) and (GroupID = %d)',[GroupInfo.GroupID]));
        sql.Add(' Order by RuleID');
{        Sql.Add('Select RuleList.* ,SoftList.SoftName as SN,'''' as MN from RuleList left join SoftList ');
        sql.Add(Format('on RuleList.SoftID=SoftList.SoftID where (GroupID = %d)',[GroupInfo.GroupID]));
        sql.Add('union');
        Sql.Add('select RuleList.*,'''' as SN,ModelList.ModelName as MN from RuleList left join ModelList ');
        sql.Add(Format('on (RuleList.ModelID=ModelList.ModelID) where (GroupID = %d)',[GroupInfo.GroupID]));
        sql.Add(' Order by RuleID');}
      end;
      if (NodeType = NodeTypeUserUp) then
      begin
        UserInfo := TVAll.Selected.Data;
        Sql.Add('Select RuleList.* ,SoftList.SoftName as SN,'''' as MN left join RuleList,SoftList ');
        sql.Add(Format('on (RuleList.SoftID=SoftList.SoftID) and (UserID = %d)',[UserInfo.UserID]));
        sql.Add('union');
        Sql.Add('select RuleList.*,'''' as SN,ModelList.ModelName as MN left join RuleList,ModelList ');
        sql.Add(Format('on (RuleList.ModelID=ModelList.ModelID) and (UserID = %d)',[UserInfo.UserID]));
        sql.Add(' Order by RuleID');
      end;
      Open;
      First;
    end;
    CBGroupExtend.OnClick(Nil);
  end;
0
 
LVL 5

Author Comment

by:tzxie2000
ID: 6933298
the sql in qryGroupRule

 if (TSRuleGroupInfo = PCInfo.Pages[PCInfo.ActivePageIndex]) then
  begin
    NodeType := GetNodeType(TVAll.Selected);
    with qryGroupRule do
    begin
      Close;
      sql.Clear;
      if (NodeType = NodeTypeGroupUP) then
      begin
        GroupInfo := TVAll.Selected.Data;
        Sql.Add('Select RuleList.* ,SoftList.SoftName as SN,'''' as MN from RuleList ,SoftList ');
        sql.Add(Format('where (RuleList.SoftID<>0) and (RuleList.SoftID=SoftList.SoftID) and  (GroupID = %d) ',[GroupInfo.GroupID]));
        sql.Add('union');
        Sql.Add('select RuleList.*,'''' as SN,ModelList.ModelName as MN from RuleList ,ModelList ');
        sql.Add(Format('where (RuleList.ModelID<>0) and (RuleList.ModelID=ModelList.ModelID) and (GroupID = %d)',[GroupInfo.GroupID]));
        sql.Add('union');
        Sql.Add('select RuleList.*,'''' as SN,'''' as MN from RuleList');
        sql.Add(Format('where (RuleList.SoftID=0) and (RuleList.ModelID=0) and (GroupID = %d)',[GroupInfo.GroupID]));
        sql.Add(' Order by RuleID');
{        Sql.Add('Select RuleList.* ,SoftList.SoftName as SN,'''' as MN from RuleList left join SoftList ');
        sql.Add(Format('on RuleList.SoftID=SoftList.SoftID where (GroupID = %d)',[GroupInfo.GroupID]));
        sql.Add('union');
        Sql.Add('select RuleList.*,'''' as SN,ModelList.ModelName as MN from RuleList left join ModelList ');
        sql.Add(Format('on (RuleList.ModelID=ModelList.ModelID) where (GroupID = %d)',[GroupInfo.GroupID]));
        sql.Add(' Order by RuleID');}
      end;
      if (NodeType = NodeTypeUserUp) then
      begin
        UserInfo := TVAll.Selected.Data;
        Sql.Add('Select RuleList.* ,SoftList.SoftName as SN,'''' as MN left join RuleList,SoftList ');
        sql.Add(Format('on (RuleList.SoftID=SoftList.SoftID) and (UserID = %d)',[UserInfo.UserID]));
        sql.Add('union');
        Sql.Add('select RuleList.*,'''' as SN,ModelList.ModelName as MN left join RuleList,ModelList ');
        sql.Add(Format('on (RuleList.ModelID=ModelList.ModelID) and (UserID = %d)',[UserInfo.UserID]));
        sql.Add(' Order by RuleID');
      end;
      Open;
      First;
    end;
    CBGroupExtend.OnClick(Nil);
  end;
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6933370
first guess,
the record is not shown because the select contains joins to other tables, where the record is not joinable

did you tried/verified the query with another frontend?
(usual with a query-tool which comes with your database)
(the requery-method should normally do the job)

meikl ;-)
0
 
LVL 5

Author Comment

by:tzxie2000
ID: 6933389
I think the select may have a little problem.but not very sure.

but my problem is that when I try the new procedure the next time it will be ok and when I run program by step it will be also ok.
????
I try the delphi 5 and 6 .all are the same.

0
 
LVL 5

Author Comment

by:tzxie2000
ID: 6933453
I think the select may have a little problem.but not very sure.

but my problem is that when I try the new procedure the next time it will be ok and when I run program by step it will be also ok.
????
I try the delphi 5 and 6 .all are the same.

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6933463
yep, thats mysterious
0
 
LVL 2

Expert Comment

by:header
ID: 6935882
Try doing a Post on the Query directly after doing the ExecSQL.

   ...
   ExecSql;
   Post;
   Close;
   ...
0
 
LVL 5

Author Comment

by:tzxie2000
ID: 6949914
when use execsql it can not post any data as it is not in edit mode.I try to add an edit before exesql,but it is still not correctly.
0
 
LVL 5

Author Comment

by:tzxie2000
ID: 6949935
when use execsql it can not post any data as it is not in edit mode.I try to add an edit before exesql,but it is still not correctly.
0
 
LVL 5

Author Comment

by:tzxie2000
ID: 6962280
could anyone help me?
0
 
LVL 5

Author Comment

by:tzxie2000
ID: 6974744
I have solved this problem myself.
let all the adoquery use the same connection can solve this problem
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6974772
well glad, you got it work,
never guessed that

ask a zero point q at community support for taking
this q into paq and refunding your points

meikl ;-)
0
 
LVL 5

Author Comment

by:tzxie2000
ID: 6976607
do you know how can I decreate the points?
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 400 total points
ID: 6976633
? decreate points

what does you mean?
if you want to get back your points, which you've invested in this q, then ask a zero-point q at community support for getting this q into paq and refunding your points.

a moderator will pick up then the q

meikl ;-)
0
 
LVL 5

Author Comment

by:tzxie2000
ID: 6976638
do you know how can I decreate the points?
0
 
LVL 2

Expert Comment

by:header
ID: 6977418
kretzschmar has just told you:

-  Go to the Community Support page http://www.experts-exchange.com/commspt/

-  Post a new question (zero points) stating that you have answered your own question and want your points back as well as the question completed.

-  Make sure to include the link to this question somewhere in your post.
http://www.experts-exchange.com/delphi/Q.20287327.html

A moderator will then take over.
0
 
LVL 5

Author Comment

by:tzxie2000
ID: 6981601
No matter you or me solve the problem,thanks for your help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

715 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