Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ado query

Posted on 2002-04-10
20
Medium Priority
?
363 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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

877 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