473,385 Members | 1,587 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,385 software developers and data experts.

How to call a SQL function in SQL server from C#?

I know how to call a stored procedure in SQL server from C# using SQLCommand
class. Could someone tell me how to call a SQL function in SQL sever from
C#?

Thanks,

Andy
Nov 15 '05 #1
2 22882
Andy,

You can call a function just like a stored procedure. However, I
believe that for the name, you can not use just the function name, but
rather, you have to use the function name prefixed by the database name.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Andy Li" <ji*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I know how to call a stored procedure in SQL server from C# using SQLCommand class. Could someone tell me how to call a SQL function in SQL sever from
C#?

Thanks,

Andy

Nov 15 '05 #2
Hi Nicholas,

At least from the Query Analizer you need to prefixe the function with the
owner of it.
I have never called a function from a .NET app. but I would try it like
this if not work then prefixed completly beggining with the DB name like:
dbname.dbo.functionName
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eb****************@TK2MSFTNGP12.phx.gbl...
Andy,

You can call a function just like a stored procedure. However, I
believe that for the name, you can not use just the function name, but
rather, you have to use the function name prefixed by the database name.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Andy Li" <ji*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I know how to call a stored procedure in SQL server from C# using

SQLCommand
class. Could someone tell me how to call a SQL function in SQL sever from C#?

Thanks,

Andy


Nov 15 '05 #3

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

Similar topics

3
by: Mariusz | last post by:
I want to write function to call another function which name is parameter to first function. Other parameters should be passed to called function. If I call it function('f1',10) it should call...
1
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when...
0
by: Frustrated | last post by:
I have an application that we are porting from Unmanaged C++ to VB.NET that involves sockets. There are two pieces to the code. One piece is a one to one TCP call to a server which is working...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
2
by: moondaddy | last post by:
I'm using vb.net and have an aspx page where I want to call a function in the code behind to do something on the backend and I want to call this function from a jscript function in the aspx page. ...
4
by: Rob Shorney | last post by:
Hi, I am using .Net 2003 , c# asp.net. The situation i have is this. I have a asp.net page which in the codebehind maintains an xml document in memory. The user can click on a button to popup a...
4
by: Bonato Pierantonio | last post by:
Hi All, It is possible inside a SCRIPT tag in the HTML page to call a SUB or FUNCTION write in the codebehind ? Example in the HTML <SCRIPT Language=vbscript> sub mySub call mySecondSub end...
5
by: Kurt Van Campenhout | last post by:
Hi, I am trying to get/set Terminal server information in the active directory on a windows 2000 domain. Since the ADSI calls for TS don't work until W2K3, I need to do it myself. I'm fairly...
19
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
11
by: yangsuli | last post by:
i want to creat a link when somebody click the link the php script calls a function,then display itself :) i have tried <a href=<? funtion(); echo=$_server ?>text</a> but it will call the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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.