怎么提高SQL查询速度(我是用ODBC)连接远程数据库
我们这里用ASP程序编程,用ODBC数据源连接远程数据库,从其数据库里取值,再进行判断,如我们数据库内有远程连接数据库中的记录,就不增加,如果没有就增加进我方数据库.但此时出现ODBC连接超时问题,我用了Server.ScriptTimeOut=360000这个语句也不起作用,远程查询一个表数据,这个表内数据有6万条.
请各位大侠同仁帮帮我.
代码如下:
<%
Server.ScriptTimeOut=36000
name="SELECT cInvCode AS code,cInvName as name, cInvStd as gg ,cenglishname as eng ,cciqcode as ccode FROM cInvenptrd where left(cInvCCode,2)='09' and cinvccode <> '0904'and cinvccode <> '0905' and cinvccode<>'0907' order by cInvCode"
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.Open name, conn, 3,1
i=1
if not rs1.eof then
rs1.movefirst
do while not rs1.eof
code1=trim(rs1.fields("code").value)
name1=trim(rs1.fields("name").value)
gg1=trim(rs1.fields("gg").value)
eng1=trim(rs1.fields("eng").value)
ccode1=trim(rs1.fields("ccode").value)
user0="select count(*) as jl from ptrdcode where cinvcode='"&code1&"' "
set user1=conn3.execute(user0)
jl=trim(user1("jl"))
if jl=0 then
sqll="Insert Into ptrdode (cinvcode,cinvname,cinvstd,cienglish,cciqcode) Values ('"&code1& " ','" &name1&" ','"&gg1&" ' ,'"&eng1&" ' ,'"&ccode1&" ' ) "
conn3.Execute sqll
end if
rs1.movenext
i=i+1
loop
end if
rs1.close
%>