473,385 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Doing a query through php to sql server 2005 and get query timeout

mikek12004
200 100+
doing a (not so simple) query -which works fine in sql server using PDO like this:
Expand|Select|Wrap|Line Numbers
  1. // attempt a connection
  2.     try {
  3.         $pdo = new PDO("mssql:host=$hostname,1433;dbname=$dbname;",$username,$password);
  4.     } catch (PDOException $e) {
  5.     die("ERROR: Could not connect: " . $e->getMessage());
  6.     }
  7.     // create and execute SELECT query
  8.     $sql = "select datepart(week,(clroot.dochdsal.date1)) as weekno,datepart(year,(clroot.dochdsal.date1)) as yearno,clroot.litmsale.linkid,SUM(clroot.litmsale.openqnt) AS ORDERQNT from clroot.dochdsal
  9.     inner join clroot.litmsale on clroot.dochdsal.aa=clroot.litmsale.documentaa
  10.     inner join clroot.DocParam on clroot.dochdsal.ParamsCode=clroot.DocParam.code
  11.     where clroot.DocParam.updorder=1
  12.     AND clroot.DocParam.stocksign=0
  13.     and clroot.dochdsal.Type1<>3
  14.     and clroot.dochdsal.FlagTrans=0
  15.     and datepart(week,(clroot.dochdsal.date1)) = '40'
  16.     and datepart(year,(clroot.dochdsal.date1)) = '2009'
  17.     GROUP BY clroot.litmsale.linkid,clroot.litmsale.cmmnt,datepart(week,(clroot.dochdsal.date1)),datepart(year,(clroot.dochdsal.date1))";
  18.     if ($result = $pdo->query($sql))
  19.     {
  20.         while($row = $result->fetch())
  21.         {
  22.             echo $row[0] . ":" . $row[1] . "\n";
  23.         }
  24.     }
  25.     else
  26.     {
  27.         echo "ERROR: Could not execute the query. " . print_r($pdo->errorInfo());
  28.     }
  29.     // close connection
  30.     unset($pdo);
  31.  
and get

Array ( [0] => HY000 [1] => 10024 [2] => SQL Server connection timed out. [10024] (severity 6) [select datepart(week,(clroot.dochdsal.date1)) as weekno,datepart(year,(clroot.dochdsal.date1)) as yearno,clroot.litmsale.linkid,SUM(clroot.litmsale. openqnt) AS ORDERQNT from clroot.dochdsal inner join clroot.litmsale on clroot.dochdsal.aa=clroot.litmsale.documentaa inner join clroot.DocParam on clroot.dochdsal.ParamsCode=clroot.DocParam.code where clroot.DocParam.updorder=1 AND clroot.DocParam.stocksign=0 and clroot.dochdsal.Type1<>3 and clroot.dochdsal.FlagTrans=0 and datepart(week,(clroot.dochdsal.date1)) = '40' and datepart(year,(clroot.dochdsal.date1)) = '2009' GROUP BY clroot.litmsale.linkid,clroot.litmsale.cmmnt,datep art(week,(clroot.dochdsal.date1)),datepart(year,(c lroot.dochdsal.date1))] [3] => -1 [4] => 6 ) ERROR: Could not execute the query. 1

any ideas?

PS already memory_limit to 300M, mssql.timeout to 1000 and max_execution_time to 1000
Dec 14 '09 #1
5 2614
ck9663
2,878 Expert 2GB
Paste your entire into a query analyzer and let's see the error. By just looking, here are some of the problems:

Expand|Select|Wrap|Line Numbers
  1.  
  2. datep art(week,(clroot.dochdsal.date1))
  3.  
  4.  
and

Expand|Select|Wrap|Line Numbers
  1.  
  2. datepart(year,(c lroot.dochdsal.date1))] [3] => -1 [4] => 6 ) 
  3.  
  4.  

Happy Coding!!!

--- CK
Dec 14 '09 #2
mikek12004
200 100+
hmmm.....those spaces that appear when doing an echo is not present in the actual query (you can see it in the code) plus in the SQL server 2005 the query runs just fine
Dec 15 '09 #3
ck9663
2,878 Expert 2GB
Then it's your connection. Check the property of your connection. How fast does your query run in Query Analyzer?

--- CK
Dec 15 '09 #4
mikek12004
200 100+
query analyzer? I run it in the new query tab of SQL 2005 and it run in about 3 mins
Dec 15 '09 #5
ck9663
2,878 Expert 2GB
If it's running properly on the query tab, my guess is it's your connection setting.

Good Luck!!!

--- CK
Dec 16 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Stefano | last post by:
Hi everibody, it's the first time i post on this newsgroup. I'm Stefano from Milano, italy. I'm a beginners with Sql2000. My problem is this. I run a View using enterprise manager and after less...
4
by: jas | last post by:
I have a basic client/server socket situation setup....where the server accepts a connection and then waits for commands. On the client side, I create a socket, connect to the server...then I...
3
by: Nils Magnus Englund | last post by:
Hi, I've made a HttpModule which deals with user authentication. On the first request in a users session, it fetches data from a SQL Server using the following code: using (SqlConnection...
4
by: VB Programmer | last post by:
When I run my ASP.NET 2.0 web app on my dev machine it works perfect. When I precomile it to my web deployment project and then copy the debug files to my web server I get this problem when trying...
1
by: traceable1 | last post by:
I have 2 SQL databases which are the same and are giving me different query plans. select s.* from hlresults h inner join specimens s on s.specimen_tk = h.specimen_tk where s.site_tk = 9 and...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
1
by: msmith | last post by:
MSSQL Server 2000 SP3 in both houston and memphis I have a database in houston, lets call it RED. Specific tables from database RED are copied to database BLUE. Database BLUE is then backed...
3
by: rcamarda | last post by:
Hello, I ran a query that I thought would take an hour, but instead took 14 hours to run. The consequence was it bogged down our data warehouse and the overnight build was adversely impacted. Is...
1
by: bimowidhi | last post by:
Hi, I'm a newbie here, and also in PHP. Sorry for my bad English. I've walked around to find the answer of my problem, but I still can't get it. I develop PHP 5.2.5 Application, using SQL...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.