473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

datasource question

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


Jul 19 '05 #1
7 2142
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" <no**@hotmail.com> wrote in message
news:eI**************@TK2MSFTNGP09.phx.gbl...
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

Jul 19 '05 #2
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:u6****************@tk2msftngp13.phx.gbl...
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" <no**@hotmail.com> wrote in message
news:eI**************@TK2MSFTNGP09.phx.gbl...
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


Jul 19 '05 #3

reformulating example :

mydatacontrol.recordsource = "select * from mytable where
myfunction(recordset.field)='valor'"
Jul 19 '05 #4
Hello,

We can have the usedr defined function "myfunction" in the query string
directly. The query string will be send to database and database can't
recognize it. If your database is SQL server 2000, you may define a UDF in
the database to take place the function. If not, you may change your query
to:

mydatacontrol.recordsource = "select * from mytable where fieldname='válór'"

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 19 '05 #5
"news.microsoft.com" <no**@hotmail.com> wrote in message
news:er*************@TK2MSFTNGP10.phx.gbl...

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


Jul 19 '05 #6
My previous post may be too brief on SQL server UDF and I should to address
more on it:

SQL User-Defined Functions allow you to define your own Transact-SQL
functions using the CREATE FUNCTION statement. It take zero or more input
parameters, and return a single value. Some user-defined functions return a
single, scalar data value, such as an int, char, or decimal value. For more
information on Sql server UDF, you may refer to:

Microsoft SQL Server 2000 User Defined Functions Whitepaper
http://support.microsoft.com/default...l%2fcontent%2f
2000papers%2fUser_defined_functions.asp

If you find that UDF's are not a solution for you, , you may refer to
Chris's suggestion. It is also a wonderful solution for this issue. Thank
for Chirs!

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 19 '05 #7
Hollo!
Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: | last post by:
Hello All, I am having a lot of difficulty trying to bind a templated column, that is programmatically created for a datagrid, to a datasource column. I have a datasource containing 2 columns,...
5
by: Sky | last post by:
What makes something a valid DataSource? What methods/iterators/etc? Why do I ask? I do understand that a DataSet is based on an XML structure...but it's too table structured for what I am...
5
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a...
4
by: Stephen | last post by:
IN VB.NET I have a form with a ListBox and would like to set the DataSource property at design-time but I can't seem to declare any kind of variable that will show up in the list. I have tried a...
7
by: bernadou | last post by:
How do I (or is this even possible) get the total number of records from a datasource control in ASP.NET 2.0? I’ve messed around with getting the row count from the grid that the datasource is...
2
by: H5N1 | last post by:
Hi there First of all excuse me posting such simple (I guess) question, but I didn't find the answer in tutorials. I have a formView presenting records from some table. one of the fields is...
1
by: AJ | last post by:
Hi all, I am trying pass a value to the DataSource method in a DataList like below. DataSource = <%# GetData(DataBinder.Eval(Container.DataItem, "ID"))%>" I get an error with this code, and am...
7
by: ThunderMusic | last post by:
Hi, This question probably went back a couple of times, but I didn't find anything about it on google, so I ask here... What is the best way to use the DataSource/DataBind pattern in a class? I...
1
by: WhiteWizard | last post by:
First my apologies, this may be longer than the normal question. I have a windows app (.NET 2.0, VS2005), and I've written a user control that will allow the user to "drag and drop" a directory...
9
pod
by: pod | last post by:
Hello I have a form which contains several textboxes and comboboxes I am able to loop through all the controls on this form and set the value (ctl.Text) to the Textboxes but if I try to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.