Discussion Locked

DataEnvironment and DataReport Problems

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Can anyone give me a handle on my issue that I am dealing with when I try to requery the commands inside my dataenvironment to make the DataReport current at that moment? VB 6.0 delivers a message to me saying that I can't perform this action on anobject that is closed, but if I code to have the recordset open before I perform the requery, it will tell me that I cannot open something that is already open. I'm puzzled, is it closed or not or possibly that is not the issue at all. Any assistance is greatly appreciated

6 replies

by rueggy

It sounds like you are opening the datalink at some point in your code and then wanting to requery it at some later point. Since the link is already active (open) it must be closed before it can be requeried. Close your link and then re-open it withyour code. It should then work.

by cb_perl

Closing the link and then reopening it causes other problems to occur, I think the problem it seems to occur after one report has closed and I am trying to access another report based upon the same data connection the DE has automatically closedmy connection after I close that report. Thus as a workaround, I have coded an On Error response to handle this eventuality.

by gbworld

I am going to say some things you probably do not want to hear, but it is the right thing to do.

First off, I hate the DE. Yes, it makes things simpler to set up. However, the added cost to performance is not worth the fact that you can drag and drop items at design time. I do not use it.

Having said that. There are easier ways to accomplish what you are trying. Here are a couple.

1. Easiest: Change the cursor type of the command object to something like Keyset or Dynamic. If the likelihood of data being added is high between DE and DR, use Dynamic. This also means you will most likely want to move the cursor to the server. This is easy, but has performance penalties.

2. Rewrite the app to use ADO objects directly. This will allow the refresh option. This has the best performance, but is the hardest to code.

There are other options in the middle, like change cursors (location to server will likely be enough as it cannot disconnect the recordset if it is server-side).
The problem here is not the recordset. It is most likely the connection. My assumption is the DE is trying to save you cycles by disconnecting the recordset. This would make sense since it is such a resource pig. The error then is on the connectionobject, not the recordset. There is no way it could be on the recordset as you are moving through it.

If I knew a bit more about the app, I might be able to lead you. For the short term, try changing cursor type and/or location. Once you get it working, it would be best to move to ADO code without the DE, if you can get this one sold. It will make your code much better performing in the long run.

A good spot to start looking for examples is:
www.vbcode.com

In the long run, you might even want to move to XML. There are good samples on www.vbxml.com. And, always keep up with MSDN at http://msdn.microsoft.com.

Gregory A. Beamer
MCP: +I, SE, SD, DBA

by gbworld

If you need a bit more help on this one, write. I will help you nail it down. I am looking at the DE for a student, so I will probably have a bit more info I can share soon.

-- Greg

by cb_perl

You are so right. I was using this DE in the hopes that it would simplify things but like most things that are too good to be true, it thinks too much for me and performs actions unbeknownst to me. I will take your advice and move to ADO code, I have wrote a quick workaround for the moment by coding an On Error exception that would handle the event.

This discussion is closed to new replies.