PC Review


Reply
Thread Tools Rate Thread

How to access an SQL function via .NET DataAdapter?

 
 
Dick Swager
Guest
Posts: n/a
 
      27th Sep 2007
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VycnkgTW9vcm1hbg==?=
Guest
Posts: n/a
 
      27th Sep 2007
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


"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
>

 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      27th Sep 2007
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" <(E-Mail Removed)> schreef in bericht
news:B9193235-1D2B-487E-83A0-(E-Mail Removed)...
> 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


 
Reply With Quote
 
Dick Swager
Guest
Posts: n/a
 
      28th Sep 2007
Thanks for the help. This stuff is so easy when you know how.

Dick

"Dick Swager" <(E-Mail Removed)> wrote in message
news:B9193235-1D2B-487E-83A0-(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
difference between dataAdapter.InsertCommand/dataAdapter.SelectCom =?Utf-8?B?UmljaA==?= Microsoft VB .NET 3 10th Nov 2006 03:34 PM
DataAdapter and MS Access =?Utf-8?B?ZWxlbmE=?= Microsoft C# .NET 1 10th Oct 2006 04:57 AM
What dataadapter should I use with an Access Database? clusardi2k@aol.com Microsoft ADO .NET 2 12th Jun 2006 09:01 PM
What dataadapter should I use with an Access Database? clusardi2k@aol.com Microsoft ASP .NET 1 12th Jun 2006 03:59 PM
Issue with UPDATE function in DataAdapter Luboš Šlapák Microsoft C# .NET 3 21st Sep 2004 07:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:35 PM.