Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing Scalar-Valued Function from VB.NET 1

Status
Not open for further replies.

tektipsFriend

Programmer
Dec 2, 2006
7
US
How do I execute a sql server scalar-valued function from vb.net? Is it just like a stored procedure?
 
Yes.

Tha commandobject has an executescalar method.

Using an SP with an OUTPUT paramater would do the same thing.

Christiaan Baes
Belgium

"My old site" - Me
 
Thanks chrissie1. This would also work. ;-)

Dim loCmd As New SqlCommand()

loCmd.CommandText = "SELECT dbo.MDate(@Year,@Month,@Day)"

loCmd.Parameters.Add("@Year", Data.SqlDbType.Int)
loCmd.Parameters("@Year").Value = 2007

loCmd.Parameters.Add("@Month", Data.SqlDbType.Int)
loCmd.Parameters("@Month").Value = 5

loCmd.Parameters.Add("@Day", Data.SqlDbType.Int)
loCmd.Parameters("@Day").Value = 1

Dim loResult As Object = DataBasics.DataSources("").ExecuteScalar(loCmd)

If loResult IsNot Nothing Then
MessageBox.Show(loResult.ToString)
End If

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top