datasource question

28/10/2003 - 21:05 por news.microsoft.com | Informe spam
Hi
I would preciate any help on calling for a fuction inside a datasource
string using visual basic.

for example:

I have one function that evaluates some condition in each recordset and
would like to create something like this:
mydatacontrol.recordsource = "select * from mytable where
myfunction(variable)='valor'"

the main idea is to replace all the 'Á' by an 'A', the 'é' by an 'e' and so
on calling the function

if i use the expression above calling myfunction i get a error
here is my code for myfunction

Public Function myfunction(cadeia As String)
Dim cacentos
Dim sacentos
Dim nciclo As Integer
Dim acento
cacentos = "áéíóúÁÉÍÓÚãõàÕâêîôûÂÊÎÔÛçÇàèìòùÀÈÌÒÙ"
sacentos = "aeiouAEIOUaoAOaeiouAEIOUcCaeiouAEIOU"
For nciclo = 1 To Len(cadeia)
acento = InStr(cacentos, Mid(cadeia, nciclo, 1))
If acento <> 0 Then
cadeia = Left(cadeia, nciclo - 1) & Mid(sacentos, acento, 1) &
Mid(cadeia, nciclo + 1)
End If
Next
myfunction= cadeia
End Function

Preguntas similare

Leer las respuestas

#1 Ray at
28/10/2003 - 21:10 | Informe spam
Wow, how many languages do you speak? Portuguese? German? Spanish?
Italian?

This isn't a classic ASP issue, as indicated by your code. I almost follow
what you're saying, and if I do:

mydatacontrol.recordsource = "select * from mytable where " &
myfunction(variable) & "='valor'"

Ray at work

"news.microsoft.com" wrote in message
news:
Hi
I would preciate any help on calling for a fuction inside a datasource
string using visual basic.

for example:

I have one function that evaluates some condition in each recordset and
would like to create something like this:
mydatacontrol.recordsource = "select * from mytable where
myfunction(variable)='valor'"

the main idea is to replace all the 'Á' by an 'A', the 'é' by an 'e' and


so
on calling the function

if i use the expression above calling myfunction i get a error
here is my code for myfunction

Public Function myfunction(cadeia As String)
Dim cacentos
Dim sacentos
Dim nciclo As Integer
Dim acento
cacentos = "áéíóúÁÉÍÓÚãõàÕâêîôûÂÊÎÔÛçÇàèìòùÀÈÌÒÙ"
sacentos = "aeiouAEIOUaoAOaeiouAEIOUcCaeiouAEIOU"
For nciclo = 1 To Len(cadeia)
acento = InStr(cacentos, Mid(cadeia, nciclo, 1))
If acento <> 0 Then
cadeia = Left(cadeia, nciclo - 1) & Mid(sacentos, acento, 1) &
Mid(cadeia, nciclo + 1)
End If
Next
myfunction= cadeia
End Function




Respuesta Responder a este mensaje
#2 news.microsoft.com
28/10/2003 - 21:12 | Informe spam
That will not evaluate each record.
I should write record instead of value
Thanks anyway

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> escreveu na mensagem
news:u6enG%
Wow, how many languages do you speak? Portuguese? German? Spanish?
Italian?

This isn't a classic ASP issue, as indicated by your code. I almost


follow
what you're saying, and if I do:

mydatacontrol.recordsource = "select * from mytable where " &
myfunction(variable) & "='valor'"

Ray at work

"news.microsoft.com" wrote in message
news:
> Hi
> I would preciate any help on calling for a fuction inside a datasource
> string using visual basic.
>
> for example:
>
> I have one function that evaluates some condition in each recordset and
> would like to create something like this:
> mydatacontrol.recordsource = "select * from mytable where
> myfunction(variable)='valor'"
>
> the main idea is to replace all the 'Á' by an 'A', the 'é' by an 'e' and
so
> on calling the function
>
> if i use the expression above calling myfunction i get a error
> here is my code for myfunction
>
> Public Function myfunction(cadeia As String)
> Dim cacentos
> Dim sacentos
> Dim nciclo As Integer
> Dim acento
> cacentos = "áéíóúÁÉÍÓÚãõàÕâêîôûÂÊÎÔÛçÇàèìòùÀÈÌÒÙ"
> sacentos = "aeiouAEIOUaoAOaeiouAEIOUcCaeiouAEIOU"
> For nciclo = 1 To Len(cadeia)
> acento = InStr(cacentos, Mid(cadeia, nciclo, 1))
> If acento <> 0 Then
> cadeia = Left(cadeia, nciclo - 1) & Mid(sacentos, acento, 1) &
> Mid(cadeia, nciclo + 1)
> End If
> Next
> myfunction= cadeia
> End Function
>
>
>
>


Respuesta Responder a este mensaje
#3 news.microsoft.com
28/10/2003 - 21:31 | Informe spam
reformulating example :

mydatacontrol.recordsource = "select * from mytable where
myfunction(recordset.field)='valor'"
Respuesta Responder a este mensaje
#4 manuel
29/10/2003 - 04:24 | Informe spam
You should use another variable to store de result,
instead of cadeia because it is used in the for/next cicle

Public Function myfunction(cadeia As String)
> Dim cacentos
> Dim sacentos
> Dim nciclo As Integer
> Dim acento, resultado
> cacentos = "áéíóúÁÉÍÓÚãõàÕâêîôûÂÊÎÔÛçÇàèìòùÀÈÌÒÙ"
> sacentos = "aeiouAEIOUaoAOaeiouAEIOUcCaeiouAEIOU"
> resultado = ""
> For nciclo = 1 To Len(cadeia)
> acento = InStr(cacentos, Mid(cadeia, nciclo, 1))
> If acento <> 0 Then
> resultado = resultado & Mid(sacentos, acento, 1)
> Else
> resultado = resultado & Mid(cadeia, nciclo, 1))
> End If
> Next
> myfunction= resultado
> End Function





Hope this help




That will not evaluate each record.
I should write record instead of value
Thanks anyway

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com>


escreveu na mensagem
news:u6enG%
Wow, how many languages do you speak? Portuguese?




German? Spanish?
Italian?

This isn't a classic ASP issue, as indicated by your




code. I almost
follow
what you're saying, and if I do:

mydatacontrol.recordsource = "select * from mytable




where " &
myfunction(variable) & "='valor'"

Ray at work

"news.microsoft.com" wrote in message
news:
> Hi
> I would preciate any help on calling for a fuction




inside a datasource
> string using visual basic.
>
> for example:
>
> I have one function that evaluates some condition in




each recordset and
> would like to create something like this:
> mydatacontrol.recordsource = "select * from mytable




where
> myfunction(variable)='valor'"
>
> the main idea is to replace all the 'Á' by an 'A',




the 'é' by an 'e' and
so
> on calling the function
>
> if i use the expression above calling myfunction i




get a error
> here is my code for myfunction
>
> Public Function myfunction(cadeia As String)
> Dim cacentos
> Dim sacentos
> Dim nciclo As Integer
> Dim acento
> cacentos = "áéíóúÁÉÍÓÚãõàÕâêîôûÂÊÎÔÛçÇàèìòùÀÈÌÒÙ"
> sacentos = "aeiouAEIOUaoAOaeiouAEIOUcCaeiouAEIOU"
> For nciclo = 1 To Len(cadeia)
> acento = InStr(cacentos, Mid(cadeia, nciclo, 1))
> If acento <> 0 Then
> cadeia = Left(cadeia, nciclo - 1) & Mid




(sacentos, acento, 1) &
> Mid(cadeia, nciclo + 1)
> End If
> Next
> myfunction= cadeia
> End Function
>
>
>
>






.

Respuesta Responder a este mensaje
#5 Chris Hohmann
30/10/2003 - 01:32 | Informe spam
"news.microsoft.com" wrote in message
news:

reformulating example :

mydatacontrol.recordsource = "select * from mytable where
myfunction(recordset.field)='valor'"



[SQL Server 2000]
SELECT * FROM mytable WHERE myfield = 'valor'
COLLATE SQL_Latin1_General_Cp850_CI_AI

[Access/SQL Server 7]
SELECT * FROM mytable WHERE myfield LIKE 'v[aáãâà]l[oóõôò]r'

In the future please indicate which database and version you are using.
If you are using SQL Server 2000, there is a topic on the COLLATE clause
in Books Online(BOL).

HTH
-Chris Hohmann
Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaSiguiente Respuesta Tengo una respuesta
Search Busqueda sugerida