Query1 won't close/Open for me in Windows 2000 Pro???

Hi!

I am using the following type of query with Delphi 5 on Windows 2000 Professional:

    with Query1 do begin
      Close;
      with SQL do begin
        Clear;
        Add('SELECT *');
        Add('FROM myDatabase');
        Add('WHERE (myDatabase."Color" = :myParam)');
      end;
      ParamByName('myParam').AsString := 'Blue';
      Open;
    end;

The query has always worked fine in Delphi and also with Windows 95A, B, 98 and NT4.

But in Windows 2000 the query does not refresh. I must manually close and reopen the program to refresh. Has anybody else experienced this problem? Or am I missing something?

Any help or guidance would be greatly accepted.

Thanking you in advance,

-Summerset
summersetAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
kambizConnect With a Mentor Commented:
Hi Summerset,

Set Query1.AutoRefresh to True.
It is better to prepare parameters of the query by Query1.Prepare before openning.

Thank you
Kambiz
0
 
rwilson032697Commented:
Why the double quotes in this line?

Add('WHERE (myDatabase."Color" = :myParam)');

Cheers,

Raymond.
0
 
kambizCommented:
Set Query1.AutoRefresh to True.
It is better to prepare parameters of the query by Query1.Prepare before openning.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
summersetAuthor Commented:
The double quotes?

In the database I am using on this project, that column has a break in the title, ie:

COLOR CHOICE

Add('WHERE (myDatabase."Color Choice" = :myParam)');

I simplified everything just to show an example of the code...I left the in "" by mistake.

Any ideas about the Query?

-S
0
 
summersetAuthor Commented:
Thanks kambiz!

That's one of those things where you just have to roll your eyes... :-)

I'm still curious why it worked in all the previous versions of Windows, but not Win2000?

Post your comment as an answer and I'll give you the points.

Thanks again!

-S
0
 
summersetAuthor Commented:
Kambiz:

It turns out that autorefresh has nothing to do with the problem. My code appears to be working fine in Win 2000, just like it did in previous versions.

The problem is (oddly) the truncated path in the desktop shortcut to this program. When I install the program (that has the query above) in Win 2000 using ISX that comes with delphi, the shortcut links to it have truncated paths in the "Start In" section of the shortcut link properties, ie:

What should be:
Start In: "C:\Program Files\MyApp Directory"

Is:
Start In: C:\Progra~1\MyApp~1

When I use the shortcut link to start the program...the SQL Queries will not refresh until I end the program and start it again.

When I start the program by double-clicking the EXE in it's directory everything works fine.

After I set Query1.AutoRefresh to True and created a new EXE, I copied it onto a floppy and then overwrote the old EXE on the test machine. I then started the program from the open directory because I had opened it to copy the file...when everything worked, I figured you had been right.

Later when I started the program again from the shortcut link -- right back to the old problem. After going back and forth for a couple of hours it finally hit me what was happening.

I spent a few hours today making sure I am correct, and also spent a great deal of time with InstallShield Express. ISX will not put the long path no matter what I do...it always truncates it. I could write 5 more paragraphs on that!

I thought I would update you on what has happened and ask if you had any ideas??

Thanks,

-S

0
 
kambizCommented:
I have two suggestions:

1. Try to use InnoSetup instead of ISX. InnoSetup is a free but powerfull installer program written by Jordan Russell.

http://www.jordanr.dhs.org/

2. Place a TSession on your form and set NetFileDir and PrivateDir properties to proper paths. Don't forget to activate the session.

Good luck,
Kambiz

0
All Courses

From novice to tech pro — start learning today.