php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51356 using COM to call MSSQL Stored Procedure
Submitted: 2010-03-23 07:42 UTC Modified: 2010-03-23 07:50 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: zhou_wen_bo at 163 dot com Assigned:
Status: Open Package: COM related
PHP Version: 5.2.13 OS: WINDOWS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: zhou_wen_bo at 163 dot com
New email:
PHP Version: OS:

 

 [2010-03-23 07:42 UTC] zhou_wen_bo at 163 dot com
Description:
------------
I wrote a Active Dll to call mssql stored procedure using ADO, something like below:

Option Explicit
Private db As New ADODB.Connection
Private adocomm As New ADODB.Command
Public Function ExecSP(sql As String) As ADODB.Recordset
    Set db = New ADODB.Connection
    db.ConnectionString = CONNECT_STRING
    db.CursorLocation = adUseClient
    db.ConnectionTimeout = 30
    db.Open
    
    Set adocomm.ActiveConnection = db
    adocomm.CommandType = adCmdStoredProc
    adocomm.CommandText = "p_Common_Pagination"     
     adocomm.Parameters(1) = sql
    adocomm.Parameters(2) = 1
    adocomm.Parameters(3) = 20
    Set ExecSP = adocomm.Execute
End Function

And Tested OK using VB code, there are some chinese characters:

Option Explicit
Private rs As New ADODB.Recordset
Private ESPTest As New espNew.espc
Private sql as String
Private Sub Command1_Click()
    sql = "select * from t_User where FUserID>1000 and FName like '%中国人%' order by FUserID"
    Set rs = ESPTest.ExecSP(sql)
End Sub

Below is the Sql Profiler's output:

exec p_Common_Pagination N'select * from t_User where FUserID>1000 and FName like ''%中国人%'' order by FUserID', 1, 20

But if I use php to call this DLL:

<?php
$sql = "select * from t_User where FUserID>1000 and FName like '%中国人%' order by FUserID";
$b= new COM("esp.espc"); 
$list=$b->ExecSP($sql);
?>

The output of the SQL Profiler is :

exec p_Common_Pagination N'select * from t_User where FUserID>1000 and FName like ''%中国人%'' order by FUserID

The second and the third parameters are missing.

I have tesed for a long time, and I'm sure the code I wroted are all right.

What's the matter ?



Test script:
---------------
like above

Expected result:
----------------
Fix the bug.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-23 07:50 UTC] zhou_wen_bo at 163 dot com
The VB Code "Private ESPTest As New espNew.espc" should be:

Private ESPTest As New esp.espc
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Oct 25 17:01:24 2020 UTC