Re: multiple query problem



J.J.Cale wrote:
Hi all
sql newbie here. The function below works as I expect on my computer,
XP IE6. i.e. I open a connection, open a recordset, fetch data, close
recordset, relplace query, open new recordset etc. Data is received
properly from both queries. BUT when I run this on another computer,
XP IE7 the BOF flag is true on the second recordset and I get "Sorry
no content" as output. I tried using a bookmark but wasn't sure what
to bookmark and don't understand the cursor style binding involved. I
also tried closing the connection and reopening it between queries but
BOF is still true on the second query. Is the problem IE version or
possibly different browser settings. Do I have to destroy the original
object and recreate? Anyone can tweak this for me or explain the
problem? TIA.
Jim

Well, being at work, I'm not going to try and plow through all this. But
I doubt this is an ADO problem. Typically you would get a "cannot
perform action while object is open" error rather than BOF if there was
a problem requiring you to destroy and recreate either your connection
or recordset objects. No, I think that if you successfully open a
recordset, and BOF is true, then the query did not return any records
and you need to investigate why. The first step is to look at the sql
statement (not the code that is supposed to result in the sql statement:
the statement that results from the code. This looks like client-side
script in a web page, so either write the contents of strQuery to a div
or alert it so you can verify that it contains what you think it should
contain.

Incidently, I don't think it makes any difference, but testing for EOF
rather than BOF immediately after opening the recordset is more
typically done. Keep in mind that you have to test for both if any
navigation is performed in the recordset (movenext, movefirst, etc)

And please: try and strip out the parts of your code that are not
necessary to illustrate your problem. for example, we really do not need
to see the code that results from a successful retrieval of data, do we?
Given that we do not have your database, it's not likely that we are
going to attempt to run your code, no is it? :-) Replace all that stuff
with a comment that says 'processing retrieved data' or something like
that. it will make us more likely to actually look at your code.

Watch out for workwrap in the sql queries. Don't forget to change
strDbPath ;>)

var adOpenDynamic = 2;
var adLockOptimistic = 3;
var strDbPath = "c:\\mypath\\mydb.mdb";
var conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
strDbPath;

<snip>
rs.open(strQuery, conn, adOpenDynamic, adLockOptimistic);


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


.



Relevant Pages

  • Re: ASP - FROM statement slows down connection to database
    ... Open your database in Access, switch to the Queries tab, create a new query ... in Design View without choosing a table, swtich to SQL View, paste the sql ... connection string rather than using an ... recordset open statements. ...
    (microsoft.public.inetserver.asp.db)
  • Re: very high cpu/ram usage: many Excel/SQL Server ADO return-trips
    ... what the endpoint of all your loops is. ... There may be a pure SQL ... > module and an ADO connection. ... though within the loop that creates a recordset I also give ...
    (microsoft.public.excel.programming)
  • Re: Emailing a Report
    ... the reason Debug.Print was done was to test the SQL of what is being generated. ... If you will add and change data here, you need to set this up as a main/subform -- or just a main form that DISPLAYS data from Users and allows modifications to Agreements. ... If you are just going to send Agreements, then AgrID should be added to the form RecordSet so you can capture it. ... maybe also some kind of category for this followup type ...
    (microsoft.public.access.modulesdaovba)
  • Re: What to do when you cant retrieve content from a DB
    ... when the SQL server goes down or the sites lose their ... SQL connection strings for pages are available from both web.config ... allowing you to close your recordset and connection immediately before ...
    (microsoft.public.inetserver.asp.db)
  • Re: ADODB.Recordset: Operation is not allowed when the object is closed
    ... > ' Create the ADO Connection and Recordset objects. ... > ' Set the connection string, open the connection and execute the ... If your sql string is an insert/update/delete statement, ...
    (microsoft.public.scripting.vbscript)