Get KoolPHP UI with 30% OFF!

Warning: sqlsrv_query() expects parameter 1

Carlos Eduardo
I'm becoming a fan of the product
Posted Jan 19, 2017 Kool -
Daniel
Hello. I had this same error message come up. After a lot of time trying to figure out the problem, I found a fix, but it doesn't make sense. Please help.
The sql statement I am using returns 7745 rows. When I ran the regular sql statment, the error "Warning: sqlsrv_query() expects parameter 1 to be resource" would show up. After a lot of time trying to figure out the problem, I decided to change the sql statement to "select top 10 ..." and that work. Well, I thought it may be a memory issue, so I kept increasing waiting for it to crash but never did. My current statement "select top 10000 ..." works fine, and 10,000 is far above the 7745 records it is importing. Why is this limit necessary? Here is the working SQL statement.
$sql = "select top 10000
case when b.type IS NULL THEN 'N/A' else b.type end as Type,
Sharpsmart_ID, Weight_lb,
SEQ,
'total' as Tot
from ".'"'."WS-2010".'"'.".dbo.PLC_Wash a
left outer join ".'"'."WS-2010".'"'.".dbo.Container_Type b
on LEFT(a.Sharpsmart_ID, 3) = b.prefix where SEQ between '2017-08-01 00:00:00:000' and '2017-08-10 09:59:59:000'
and Manifest != 'REWASH' order by b.type";

$ds = new SQLSRVPivotDataSource($dbcon);
$ds ->selectCommand($sql);
Here is the failing statement:
$sql = "select
case when b.type IS NULL THEN 'N/A' else b.type end as Type,
Sharpsmart_ID, Weight_lb,
SEQ,
'total' as Tot
from ".'"'."WS-2010".'"'.".dbo.PLC_Wash a
left outer join ".'"'."WS-2010".'"'.".dbo.Container_Type b
on LEFT(a.Sharpsmart_ID, 3) = b.prefix where SEQ between '2017-08-01 00:00:00:000' and '2017-08-10 09:59:59:000'
and Manifest != 'REWASH' order by b.type";
$ds = new SQLSRVPivotDataSource($dbcon);
$ds ->selectCommand($sql);
Everything else is the same! For now the top 10,000 is fine, but my data may grow and surpass the 10,000 limit and I will be screwed. I need to have this sql statement working without the top 10,000 limit. Thanks for any help.
"
Posted Sep 4, 2017 , edited Sep 4, 2017 Kool