Sunday, March 25, 2012

Calling SQL function in C#

Hello,

I am trying to call a SQL Function in C#, as I want to get the value binded back to the column in a datagrid.

Any answers will be appreciated ............Urgent.

:)

coinsdrop, dont know of a way using ado.net to call functions. but as a work around, you could create a stored procedure and select avariable which is set to the value of the function. then youcould use a Sql Command object and call the stored procedureprogrammatically. hope this is helpful. -- jp|||

Hi coinsdrop,

This depends on what kind of result you're retrieving.

If you're getting a record collection as result set, you can create a SqlDataAddapter, fill the result of a SELECT statement to a DataSet.

If you're trying to return some single value, you can use output parameters or return value.

I suggest you take a look at the ADO.NET tutorial. It covers all these technologies.

http://msdn2.microsoft.com/en-us/data/aa937699.aspx

HTH. If this does not answer you question, please feel free to mark it as Not Answered and post your reply. Thanks!

No comments:

Post a Comment