Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Updateing DBGrid after submitting a SQL update

Posted on 1998-04-02
14
Medium Priority
?
188 Views
Last Modified: 2010-04-06
I use Delphi 3.0 and im accessing a MSAccess 97 database thru ODBC. I have a TTable connected to
the database. I use SQL to update a record in the database. All the records are shown in a DBGrid.
When  updateing I update the selected one.
How do I get update in the DBgrid??
How do i get focus on the updated record??
I have tried:
Table.Active:=False;
Table.Active:=True;
to get the update (i works), but how do I get focus on the changed record ???
Is there a better way then opening and closeing the table??
0
Comment
Question by:mny
[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
  • 7
  • 3
  • 3
  • +1
14 Comments
 

Author Comment

by:mny
ID: 1361222
Edited text of question
0
 

Author Comment

by:mny
ID: 1361223
Edited text of question
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1361224
1. Use Table.Refresh to see the new details.
2. Use FindKey or Locate to select the record you want.

0
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.

 

Author Comment

by:mny
ID: 1361225
I have tried to use Table.Refresh but I get an error meassage
from ODBC lookin like this:
genaral SQL Error.
[Microsoft][ODBC microsoft Access 97 Driver]Wrong number of parameters
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1361226
I have made Refresh to an Informix Table via ODBC and it worked well.
What version of BDE do you have?
0
 

Author Comment

by:mny
ID: 1361227
Im using BDE 4.00, and I'm using a Access 97 (.mdb) database.
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1361228
I suggest you upgrade your BDE to version 4.51, then we will be wiser.
I know there are problems with BDE 4.0 and ACCESS.
Download Bde_upg.exe from the Borland site.
0
 

Expert Comment

by:bijoyn
ID: 1361229
Hello,

What u may do is to do a locate on the table for the record u just updated. This will bring the focus automatically to the corresponding row of the grid. Is there a specific reason for using a TTable component instead of a TQuery component ?. U can of course do the same thing with the TQuery component after making the update.

Cheers,

bijoy
0
 
LVL 1

Accepted Solution

by:
mrider earned 200 total points
ID: 1361230
you can use procedure like this:

procedure RefreshTable(var T:TTable);
var MyBookmark: TBookmark;
with T do
  begin
  MyBookmark := GetBookMark;
  T.Active:=false;
  T.Active:=true;
  GotoBookMark(MyBookMark);
  FreeBookmark(MyBookmark);
  end;

it will re-read table and put your on previos active record

0
 

Author Comment

by:mny
ID: 1361231
Well it works fine but....
I have a DBGrid connected to my table and bookmark works fine if i
only use it on records that fit in the grid with out scrolling it.
Say: I have 30 rows in my grid and I have say 40 records in the table.
If i bookmark the 31:st and up to 40 i get:
genaral SQL Error.
       [Microsoft][ODBC microsoft Access 97 Driver]Wrong number of parameters

What to do about that???
0
 
LVL 1

Expert Comment

by:mrider
ID: 1361232
first, try to use native BDE to access Access ;)
it exists in delphi 3
second, how are you bookmarking you 31st record?
it is not physical number in normal database, you must
use finding record (see findkey routing)
so, when you go to 31st record using finding condition(ex. FindKey or GotoKey) DBGRID must do it record visible instead of if you'll use table1.disablecontrols.
I think, something wrong with you using of navigation



0
 

Author Comment

by:mny
ID: 1361233
Ok its like this:
When i try to open the DB-alias (produced in ODBC32) in BDE i can open it,
but it won't let me look at the tables.

In my last comment I meant that in the program I'm building i have
a DBGrid that atmost have 30 rows visible. If i want to see the "31:st" record i have to
scroll down in the grid. Then my program lets me "dubbelclick" one record. The program
then presents a dialogbox where I edit the record. When I click "OK" an SQL updates
the record. Then I close and open the table to get it "updated" and the i would like
the record i just changed to be "highlighted". It works as long as i do it to the "30" first
records, but does not work if i scroll down and changes the "31:st"

0
 
LVL 1

Expert Comment

by:mrider
ID: 1361234
hmmm..... can you show part of code which do this action?

0
 

Author Comment

by:mny
ID: 1361235
I have solved it!!

I upgraded the BDE from 4.00 to 4.51 and then it worked
fine.
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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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 video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

618 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