|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to access an SQL function via .NET DataAdapter?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 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 Show quote "Dick Swager" wrote: > 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 > 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 Show quote "Dick Swager" <cswager.n.o.s.p.***@cox.net> schreef in bericht news:B9193235-1D2B-487E-83A0-69D88F1AB341@microsoft.com... > 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 Thanks for the help. This stuff is so easy when you know how.
Dick Show quote "Dick Swager" <cswager.n.o.s.p.***@cox.net> wrote in message news:B9193235-1D2B-487E-83A0-69D88F1AB341@microsoft.com... > 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 |
|||||||||||||||||||||||