473,472 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SQLDataSource - ExecuteScalar

I would like to return one specific value from an SQLDataSource configured
to a table with an SQL Command selecting a specific value.
It would be the equilivant of ExecuteScalar in OLEDB.
Replies with code would be appreciated.
Thanks Jim
Jun 20 '06 #1
1 3284
Jim, any SQLDataSource should be able to do this, but I dont believe
you can write such a statement in the VS2005 wizard for creating the
data source. Instead, you will have to go into your code and write your
own SQL statement.

Try modifying this with your own connection string and sql string and
then set the GridView / DataGrid / whatever to use it as a data source.

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT COUNT(*) FROM [Table]">
</asp:SqlDataSource>

Jeff

Jim McGivney wrote:
I would like to return one specific value from an SQLDataSource configured
to a table with an SQL Command selecting a specific value.
It would be the equilivant of ExecuteScalar in OLEDB.
Replies with code would be appreciated.
Thanks Jim


Jun 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: bienwell | last post by:
Hi all, I have a problem with using myCommand.ExecuteScalar(). My question is : If the Web setup is incorrect, does it make command ExecuteScalar() work improperly ?? In my program, I was...
5
by: Martin Bischoff | last post by:
Hi, is it possible to modify the values of a SqlDataSource's select parameters in the code behind before the select command is executed? Example: I have an SqlDataSource with a...
6
by: VB Programmer | last post by:
I have a sqldatasource on a webform. How do I (in code) retrieve the value of a particular column in the first row? Do I have to save the sqldatasource SELECT results into a datatable and look at...
3
by: Jim Andersen | last post by:
Just to let you know, and to help any future sorry sods who gets trapped in the same black hole...... You can't just copy/move a working sql-statement into a stored procedure. Working with a...
3
by: Bill | last post by:
This is probably easy but I cannot find it... All I want to do is read the data out of a SQLDataSource programmatically to test if there are any records. I don't want to bind it to a control ...
2
by: djc | last post by:
1) I am wondering if I should be using an sqlDataSource object for my particular scenario. I need to loop through a listbox and perform an INSERT sql operation for each item. Could be a few or...
1
by: Per W. | last post by:
Hi, is there som other way to do this? i only want the result from the select statement so i can use it in my code. I dont need the gridview, but this is the only way i got it to work. The...
7
by: Arjen | last post by:
Hi, This are the lines I have now: SqlDataSource1.SelectCommand = "SELECT TOP (1) RangeId FROM myTable"; SqlDataSource1.SelectParameters.Add(new Parameter("RangeId", TypeCode.Int32)); int...
1
by: Pipo Dyer | last post by:
Hello Everybody, I am Using @@IDENTITY from MS Access (YES-It is possible) using SqlDataSource -NO STORE PROC- in ASP.NET {VB CODE} to retrieve the ID of a inserted record. Please keep in mind I...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.