Wouldn't you need to specify the parameters in the CommandText also? Not
sure, I don't work with many UDF's from VB.NET:
sqlCmd.CommandText = "select * from R_SiphonDetailForDays (@sDate, @sDate2)"
[quoted text, click to view] "Stephany Young" <noone@localhost> wrote in message
news:OkwE6T4LFHA.580@TK2MSFTNGP15.phx.gbl...
> Try
> CommandType.Text and
> ConmmandText = "select * from R_SiphonDetailForDays"
>
> "Roger" <davisro@netins.net> wrote in message
> news:%23O1HO5uLFHA.3336@TK2MSFTNGP09.phx.gbl...
>>I get an error stating this call is to a function not a stored procedure?
>> How do I call a stored function in SQL Server from vb.net
>>
>> Thanks....
>>
>>
>> asp.Net Code..... (VB)
>>
>> sqlCmd = New SqlClient.SqlCommand("R_SiphonDetailForDays",
>> sCon) sqlCmd.CommandType = CommandType.StoredProcedure
>> sqlCmd.Parameters.Add("@sDate", Session("Date"))
>> sqlCmd.Parameters.Add("@sDate2", Session("Date")) rdr =
>> sqlCmd.ExecuteReader(CommandBehavior.Default)
>> DataGrid1.DataSource = rdr
>> DataGrid1.DataBind()
>>
>>
>> T-SQL Stored Function
>>
>> ALTER FUNCTION dbo.R_SiphonDetailForDays
>> (
>> @sDate nvarchar(10),
>> @sDate2 nvarchar(10)
>> )
>> RETURNS TABLE
>> AS
>> RETURN ( SELECT SiteNum, FileDate, FileName, FileExt, FileSize
>> FROM a_SiphonDetail
>> WHERE (FileDate > CONVERT(smalldatetime,
>> CONVERT(varchar(10),
>> DATEADD(day, - 1, @sdate), 101)) + '10:00 PM') AND (FileDate <
>> CONVERT(smalldatetime,
>> CONVERT(varchar(10), @sdate2), 101) +
>> '10:00
>> PM') )
>>
>>
>>
>
>