Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 11th, 2006, 08:19 AM
Authorized User
 
Join Date: Nov 2005
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
Default Speeding up DB search, how?

Hi,

I have three different tables, two in DBF (for getting the data)and another in SQL (for writing the new table)
====
sql="SELECT * FROM M_SALSIN"
rs.open sql, conn
DO WHILE NOT RS.EOF
     sql3="SELECT * FROM MAE_CLI WHERE COD_CLI="&TRIM((rs("cod_cli")))&""
    rs3.open sql3,conn
    IF rs3.EOF THEN
    ELSE
    sql5="INSERT INTO CINTAS_PDA_SIN_CARGO_MAIN(cod_alb,cod_cli,fecha,te rminado) VALUES('"&rs("cod_alb")&"','"&rs("cod_cli")&"','29/11/2006','0')"
    rs5.open sql5, conn5
    END IF
    rs3.close
    rS.MOVENEXT
LOOP
===
First I open a DB with the new data.
Then I enter the loop, where I search the table of the names, so that I can INSERT the data of the first SQL, with the name of the second SQL statement.

I noticed that this is just taking to long. As everytime it has to open the DB connection....
Does anybody can give me some tips on doing this better, so that it might take less time to do the process.

The idea is that it runs at 3 a.m. to prepare the new table for the next morning.

Many thx for any idea.

Johny


 
Old December 11th, 2006, 09:53 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

If this was all in MSSQL I could do this with 1 query.

INSERT INTO CINTAS_PDA_SIN_CARGO_MAIN(cod_alb,cod_cli,fecha,te rminado)
SELECT cod_alb, cod_cli, '29/11/2006', '0' FROM MAE_CLI WHERE COD_CLI IN (SELECT cod_cli from M_SALSIN)

The WHERE Clause could also just be COD_CLI = (SELECT DISTINCT cod_cli from M_SALSIN) if there is only 1 cod_cli in the table.

If you can use the above query,you will only have to make 1 connection to your database and it should run 100 times faster then what you are tying to do.


-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old December 12th, 2006, 07:21 AM
Authorized User
 
Join Date: Nov 2005
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Thx dparsons,

I will give it a shot. I was already looking in that direction. As you statet, it must speed up the search...

Thx again

Johny


 
Old December 18th, 2006, 09:04 AM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Write it as a Stored Procedure in SQL and then set it to be a job in the SQL Server Agent, timed to run daily at 3am.

Regards,

Sean Anderson





Similar Threads
Thread Thread Starter Forum Replies Last Post
Search button doesn't search Access DB cbones Visual Studio 2008 1 October 27th, 2008 07:36 PM
Speeding up processing time on ASP file sswingle Classic ASP Databases 2 April 14th, 2006 04:51 AM
Q about search DB... ugmos Classic ASP Databases 1 February 27th, 2006 07:49 PM
Speeding up an application with linked tables lguzman Access VBA 0 August 26th, 2004 10:13 AM
How to search entire DB[?] Blaise SQL Server 2000 7 June 11th, 2003 09:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.