Groups | Blog | Home
all groups > dotnet ado.net > september 2007 >

dotnet ado.net : How to access an SQL function via .NET DataAdapter?


Kerry Moorman
9/26/2007 6:26:00 PM
Dick,

Use a command object, for example an SQLCommand object if you are working
with SQL Server.

You can use the command object's ExecuteScalar method to retrieve a single
value.

Kerry Moorman


[quoted text, click to view]
Dick Swager
9/26/2007 7:19:35 PM
Is there a way to use a DataAdapter to retrieve data via an SQL function? I
have done what I need to do using a stored procedure that returns a 1x1
table, but it seems like it would be much cleaner if the single value
returned by a function could be obtained. Maybe there is some mechanism
other than a DataAdapter. I've been away from this stuff for a while and
I'm trying to re-learn a lot of the C++ / SQL interaction stuff with .NET.

Dick
Cor Ligthert[MVP]
9/27/2007 12:00:00 AM
Dick,

Beside the by Kerry told executescalar there is as well the datareader,
which gives you a row back from the resultset. There are more kind of
adapters, however those are generated using the dataadapter (while the
dataadapter is in fact using the datareader).

http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader(VS.71).aspx

Cor

"Dick Swager" <cswager.n.o.s.p.a.m@cox.net> schreef in bericht
news:B9193235-1D2B-487E-83A0-69D88F1AB341@microsoft.com...
[quoted text, click to view]
Dick Swager
9/27/2007 7:23:48 PM
Thanks for the help. This stuff is so easy when you know how.

Dick

[quoted text, click to view]
AddThis Social Bookmark Button