How to call a SQL Server UDF from ASP.NET
Here is a sample code to call a SQL Server UDF (User Defined Function) from ASP.NET
Sub GetNotes(contnum integer)
Protected objCon As New SqlConnection(ConfigurationSettings.AppSettings("conn"))
Dim cmdtrans As SqlCommand,notes as string
dim sqltrans as string ,popnotes as string
sqltrans= "select dbo.fnpop_notes(@contnum)"
cmdtrans=new sqlcommand(sqltrans,objCon)
cmdtrans.Parameters.Add(New SQLParameter("@contnum",contnum))
If objCon.State = 0 Then objCon.Open()
notes=cmdtrans.ExecuteScalar()
objCon.Close()
end sub
The code above is pretty much self xplanatory.
Based on a feedback I received from I am adding a link to another article that tells you another ( better) way to do this. Heres the link : http://www.ftponline.com/vsm/2003_09_14th/online/hottips/rehak/