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:
Mostrar la cita
so
Mostrar la cita
#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%
Mostrar la cita
follow
Mostrar la cita
#3 news.microsoft.com
28/10/2003 - 21:31 | Informe spam
reformulating example :

mydatacontrol.recordsource = "select * from mytable where
myfunction(recordset.field)='valor'"
#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)
Mostrar la cita
Hope this help




Mostrar la cita
escreveu na mensagem
Mostrar la cita
German? Spanish?
Mostrar la cita
code. I almost
Mostrar la cita
where " &
Mostrar la cita
inside a datasource
Mostrar la cita
each recordset and
Mostrar la cita
where
Mostrar la cita
the 'é' by an 'e' and
Mostrar la cita
get a error
Mostrar la cita
(sacentos, acento, 1) &
Mostrar la cita
#5 Chris Hohmann
30/10/2003 - 01:32 | Informe spam
"news.microsoft.com" wrote in message
news:
Mostrar la cita
[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
Ads by Google
Search Busqueda sugerida