473,782 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ 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 3299
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:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring %>"
SelectCommand=" SELECT COUNT(*) FROM [Table]">
</asp:SqlDataSour ce>

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
2124
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 using ExecuteScalar() to count the number of records from the query. The return value is always 0. If number record is 0 then it will go the Page1.aspx page by (response.redirect) . If not, it will go to Page2.aspx page. The result is it's...
5
4481
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 ControlParameter <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:XYZ %>"
6
3378
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 it that way? A code sample would help. Thanks!
3
6413
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 sqldatasource. Conflictdetection set to compareallvalues. Oldvaluesparameterformatstring set to original_{0} tblA has 2 fields. ID and MyText. Deletecommand="Delete from tblA where ID=@original_ID"
3
2904
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 I expected to be able to use it like the below Dim ds as dataset SqlDataSource1. fill ( ds) ' does not work
2
1998
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 several items. The reason I'm wondering if I should use an SqlDataSource object is overhead. For example, prior to learning about the sqlDataSource I would just code the ado.net procedure myself. For example, create connection object, create and...
1
2660
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 SqlDataSource component is on the .aspx page and my code is on the aspx.vb page Protected sub in the aspx.vb page
7
39289
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 rangeId = ... How do I get the result from the database in the variable? I tried a lot of
1
3100
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 am using a form page an code behing, and I have currently my ConnectionString within my form. Therefore http://www.mikesdotnetting.com/Article.aspx?ArticleID=54 was close but not exactly what I need at this point. So far I have done the following...
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10143
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10076
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8964
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7486
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5375
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5507
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.