简体   繁体   中英

Partial data returned from database query in classic asp

Has anyone ever encountered a problem where a SQL query from a classic ASP page returns partial results, but no errors?

I have a situation where a particular query on a page (one of many throughout the system) is returning a different number of rows each time it is run, and always less than the "correct" number, as determined by running the SQL against the server directly.

I think this may be related to the connection timeout (since this occurs with a long-running query and my timing shows that it is returning very close to the timeout), but I am receiving no timeout errors. Instead, as far as I can tell, it causes no errors, and returns a valid DataSet which the code then loops over to build the results table.

Since there is no indication that an error has occurred, there is no suggestion that the data is not complete which means that users can no longer trust this report. Generally with this system, where SQL timeouts do occur frequently for "large" queries, we get error messages displayed on the page.

Investigations

  • I've check the HTML source to make sure there are no injected error's that I'm missing and that all tags are well-formed and that expected page elements are present. This indicates it's not an error writing a particular row from the results. ** Furthermore, the number of rows returned is different each time.
  • I've verified that the exact same query is being run each time.
  • I've verified that the data in the DB is not changin underneath the report (it's historic and I've cross-checked by running the report and the query against the DB at the same time.)
  • I've tried to manually print any errors from the query , but get nothing.
  • I've tried changing the timeout (though this hasn't helped as I can only do this on the Dev environment and there there is not sufficient data in the DB to reach the timeout, due to this issue.).
  • There are only around 20 rows in total expected, so not an issue with a very large dataset.

Has anyone run into a situation where a SQL query from a classic asp page only returns partial results, and is there any way to check for or prevent this condition?

Setup :

  • Classic asp web application
  • Heavy use throughout of ADODB.Connection objects for connecting to the DB2 server backend databases.
  • The database is static as far as the queried data is concerned.

Shared connection initilization as follows:

connString = "Provider=MSDASQL.1;User ID=xxx;Data Source=XXX;Extended Properties=""DSN=XXX;UID=XXX;PWD=XXX;"""
Set conn = Server.CreateObject( "ADODB.Connection" )
Set cmd = Server.CreateObject("ADODB.Command")
conn.Mode = adOpenReadOnly
conn.Open connString
cmd.ActiveConnection = conn
cmd.CommandTimeout = 600

Usage as follows:

query = " SELECT blah FROM Foo WHERE ... " ' big long list of clauses defined from user selections.
cmd.CommandText = sql
Set oRs = cmd.Execute

Resposne.Write "<table>..." ' Write table headers here'
Do while (Not oRs.eof)
     Response.Write "<tr>...</tr>" ' WRite details from oRs here
     oRs.MoveNext
Loop
Response.Write "</table>"

尝试向查询中添加order by ,这样它应该一次发送所有行,并且可以排除超时问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM