Proba de usar tipo de datos NVARCHAR en lugar de VARCHAR

SALUDOS




Mensaje citado por: Claudia Esther Abad <[EMAIL PROTECTED]>:

> A ver si alguien me puede ayudar. Tengo esta funci�n que busca un > stored
> procedure en la BD. Extrae sus par�metros y de la cadena ActualValues
> extrae los valores para ejecutar el stored procedure. El problema es que
> los par�metros de tipo varchar, si por ejemplo, es de longitud 40 y le
> paso al par�metro �%pepe%� , me completa con espacios hasta > completar 
> la
> longitud del campo y eso le pasa al stored procedure. Ahora estamos
> trabajando con SQL 2000, anteriormente con SQL 7 esto no pasaba.
>  
> C�mo lo puedo solucionar? Alguna idea? Prob� ponerle Trim, Ltrim, > etc. Y
> nada, siempre me completa la longitud del campo.
>  
> Gracias,
> Claudia.
>  
> Public Function StoredProcedures(SQLConnection As ADODB.Connection,
> ProcedureName As String, Optional ActualValues As String) As
> ADODB.Recordset
>     
>     Dim ParametersInfo() As String
>     Dim ParametersList() As String
>     Dim ParametersValues() As String
>     
>     Dim ADOcmd As ADODB.Command
>     Dim oParam As ADODB.Parameter
>     Dim bReturnParamFlag As Boolean
>     
>     Dim Index As Integer
>     Dim i As Integer
>     
>     Dim AllParameters As ADODB.Recordset
>     
>     Dim paramType As String
>     Dim paramNro As Integer
>     
>     On Error GoTo errStored
>     
>     bReturnParamFlag = False
>     
>     Set ADOcmd = New ADODB.Command
>     Set ADOcmd.ActiveConnection = SQLConnection
>     
>     Set AllParameters =
> SQLConnection.OpenSchema(adSchemaProcedureParameters)
>     
>     Index = 0
>     
>     Do While Not AllParameters.EOF
>        If AllParameters!PROCEDURE_NAME = ProcedureName & \";1\" Then
>        
>           paramNro = AllParameters.Fields(5).Value
>             
>           Select Case paramNro
>              Case adParamOutput:
>                 paramType = \"OUTPUT\"
>              Case adParamInputOutput:
>                 paramType = \"INPUT/OUTPUT\"
>              Case adParamInput:
>                 paramType = \"INPUT\"
>              Case adParamReturnValue:
>                 paramType = \"RETURN VALUE\"
>              Case adParamUnknown:
>                 paramType = \"UNKNOWN\"
>           End Select
>           ReDim Preserve ParametersInfo(Index + 1)
>           ParametersInfo(Index) = AllParameters!PARAMETER_TYPE & > Chr(9)
> & paramType & Chr(9) & AllParameters!PARAMETER_NAME & Chr(9) &
> AllParameters!TYPE_NAME & Chr(9) & AllParameters!DATA_TYPE & Chr(9) &
> AllParameters!CHARACTER_MAXIMUM_LENGTH
>        
>           AllParameters.MoveNext
>        
>           Index = Index + 1
>        Else
>           AllParameters.MoveNext
>        End If
>     Loop
>         
>     If Not IsNull(ActualValues) Then
>         
>         \'Crea el array con los valores de los par�metros
>         ParametersValues = Split(ActualValues, \";\")
>         
>         \'Crea los objetos Parameters
>         For i = 0 To Index - 1
>            ParametersList() = Split(ParametersInfo(i), Chr(9))
>            Set oParam = ADOcmd.CreateParameter
>            oParam.Name = ParametersList(2)
>            oParam.Type = ParametersList(4)
>            oParam.Direction = ParametersList(0)
>            If oParam.Type = 129 Or oParam.Type = 130 Then
>               oParam.Size = ParametersList(5)
>            End If
>            If oParam.Direction = 4 Then
>               bReturnParamFlag = True
>            End If
>            If oParam.Direction = 1 Then \'adParamInput
>               If bReturnParamFlag = False Then
>                  oParam.Value = ParametersValues(i)
>               Else
>                  \'Si el par�metro es tipo texto
>                  If (oParam.Type = 129 Or oParam.Type = 130) Then
>                     If (ParametersValues(i - 1) = sEmptyString) Then
>                         oParam.Value = Null
>                     Else
>                         oParam.Value = LTrim(ParametersValues(i - 1))
>                     End If
>                  \'Si el par�metro es tipo num�rico y adem�s es > 
> vac�o
>                  ElseIf (ParametersValues(i - 1) = sEmptyString) And
> (oParam.Type = 3) Then
>                     oParam.Value = 0
>                  Else
>                     oParam.Value = ParametersValues(i - 1)
>                  End If
>               End If
>            End If
>            ADOcmd.Parameters.Append oParam
>         Next i
>     
>     End If
>     
>     ADOcmd.CommandText = ProcedureName
>     ADOcmd.CommandType = adCmdStoredProc
>     Set StoredProcedures = ADOcmd.Execute
>     
>     Exit Function
>     
> errStored:
>  
>     Err.Raise Err.Number, \"StoredProcedures\", Err.Description
>
> -- 
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 269.3.0/758 - Release Date:
> 12/04/2007 11:52 a.m.
>  
> 

__________________________________
Registrate desde 
http://servicios.arnet.com.ar/registracion/registracion.asp?origenid=9 y 
participá de todos los beneficios del Portal Arnet.

Responder a