Re: msdatashape provider error
- From: wq352 <wq352@xxxxxxx>
- Date: Mon, 22 Jan 2007 18:04:41 -0800
--
wq352
"Bob Barrows [MVP]" wrote:
wq352 wrote:
I usually used the MSDASQL.1 provider to access SQL Server
Well, then, you've been using a deprecated provider.
http://www.aspfaq.com/show.asp?id=2126
but now IFirst, try changing to the SQLOLEDB provider. If that does not help, show us
need to use the MSDatashape as the provider and used MSDASQL.as the
data provider. And here lies the problem, my codes which uses ADO
command refresh to get the parameters from store procedure does not
work in my vb code and return error message:
1: [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 'stored
procedure name' expects parameter 'parametername', which was not
supplied.
2: Data provider or other service returned an E_FAIL status.
Does anyone know why MSDatashape cannot seems to be able to detect
any of the in/out parameters of a stored procedures?
some code to repro the symptom.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Thank you very much,
When I only use 'Provider=MSDASQL.1' or 'Provider=SQLOLEDB.1' ,It's ok.
If I use the MSDatashape as the provider and used original provider as the
data provider,It returned error.
sample code:
Test Function:
Private m_objConn As ADODB.Connection
Private Sub cmdExec_Click()
Dim cmdProcedure As ADODB.Command
Dim lngEffectedRows As Long
Set cmdProcedure = New ADODB.Command
Set cmdProcedure = ExcuteProcedure("dbo.usp_ProviderTest", 2,
lngEffectedRows)
End Sub
Public Function ConnectDB(objConnection As ADODB.Connection) As Boolean
Dim strConn As String
Dim strErrDesc As String
On Local Error GoTo errHandle:
If objConnection Is Nothing Then
Set objConnection = New ADODB.Connection
End If
If objConnection.State = adStateClosed Then
objConnection.CursorLocation = adUseClient
objConnection.ConnectionTimeout = 30
objConnection.CommandTimeout = 300
End If
strConn = "Provider=MSDataShape;Data Provider=MSDASQL.1;Persist Security
Info=False;"
'strConn = "Provider=MSDASQL.1;Persist Security Info=False;"
' strConn = "Provider=MSDataShape;Data Provider=SQLOLEDB.1;Persist
Security Info=False;"
' strConn = "Provider=MSDataShape;driver={SQL Server};Persist Security
Info=False;"
strConn = strConn & "Data Source=[strDSN];"
strConn = strConn & "User ID=[strUserName];"
strConn = strConn & "password=[strPassword];"
'''' strConn = strConn & "Server=HI1-BOCIM;"
'''' strConn = strConn & "database=BQZ_PICS;"
'''' strConn = strConn & "UID=pics;"
'''' strConn = strConn & "pwd=snp1479;"
objConnection.Open strConn
ConnectDB = True
Exit Function
errHandle:
strErrDesc = "[(" & 1051 + vbObjectError & ")(" & App.Title &
")(ConnectDB)]" & Err.Description
Err.Raise 1000 + vbObjectError, , strErrDesc
End Function
Public Function ExcuteProcedure(ByVal strProcedureName As String, ParamArray
ParamInputList()) As ADODB.Command
Dim strErrDesc As String
Dim cmdProcedure As ADODB.Command
Dim lngProceParamCount As Long
Dim lngParamInputCount As Long
Dim intCount As Integer
Dim varParamInputList As Variant
Dim intParamCount As Integer
Const ParameterSize = 65536
On Error GoTo Error_Handler
'Init Parameter list
If UBound(ParamInputList) >= 0 Then
varParamInputList = ParamInputList
End If
'refresh connction
If m_objConn Is Nothing Then
Set m_objConn = New ADODB.Connection
End If
OpenConn:
If m_objConn.State = adStateClosed Then
Call ConnectDB(m_objConn)
End If
'Init ADO.command
Set cmdProcedure = New ADODB.Command
Set cmdProcedure.ActiveConnection = m_objConn
cmdProcedure.CommandText = Trim$(strProcedureName)
cmdProcedure.CommandType = adCmdStoredProc
cmdProcedure.Parameters.Refresh
With cmdProcedure
'Check Parameter
lngProceParamCount = .Parameters.Count
'Set parameter value
intParamCount = 0
For intCount = 0 To lngProceParamCount - 1
If .Parameters(intCount).Type = adChar Or
..Parameters(intCount).Type = adVarChar Then
.Parameters(intCount).Type = adBSTR
End If
If .Parameters(intCount).Direction = adParamInput Or
..Parameters(intCount).Direction = adParamInputOutput Then
If IsNull(varParamInputList(intParamCount)) Or
IsEmpty(varParamInputList(intParamCount)) Then
Else
.Parameters(intCount).Size = .Parameters(intCount).Size
.Parameters(intCount).Value =
Trim(varParamInputList(intParamCount))
End If
intParamCount = intParamCount + 1
End If
Next intCount
.Execute
End With
Set ExcuteProcedure = cmdProcedure
Exit Function
Error_Handler:
strErrDesc = "[(" & 1051 + vbObjectError & ")(" & App.Title &
")(ExcuteProcedure)]" & Err.Description
Set cmdProcedure = Nothing
Err.Raise 1000 + vbObjectError, , strErrDesc
End Function
Test Storde Procedure:
CREATE PROCEDURE dbo.usp_ProviderTest
(
@pintIn INT,
@pintOut INT=0 OUTPUT
)
AS
BEGIN
set @pintOut=20
RETURN 0
End
.
- Follow-Ups:
- Re: msdatashape provider error
- From: Bob Barrows [MVP]
- Re: msdatashape provider error
- References:
- Re: msdatashape provider error
- From: Bob Barrows [MVP]
- Re: msdatashape provider error
- Prev by Date: Re: Stand Alone Recordsets
- Next by Date: Re: msdatashape provider error
- Previous by thread: Re: msdatashape provider error
- Next by thread: Re: msdatashape provider error
- Index(es):
Relevant Pages
|
|