473,785 Members | 2,887 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using SQLDataSource without a control?

This is probably easy but I cannot find it...

All I want to do is read the data out of a SQLDataSource programmaticall y 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

So, can this be done or do I need to create a hidden gridview to receive the
data?

Thanks

Bill
Aug 24 '06 #1
3 2904
"Bill" <aa@ss.comwro te in
news:4d******** *********@torna do.tampabay.rr. com:
All I want to do is read the data out of a SQLDataSource
programmaticall y to test if there are any records.
Use a SQLCommand object... and execute a scalar command like "SELECT COUNT
(1) FROM TABLE"

http://msdn2.microsoft.com/en-
us/library/system.data.sql client.sqlcomma nd.executescala r.aspx
Aug 24 '06 #2
RJ
I agree with using "Select Count(*)" with a cmd.executeScal er.

But, In your example with DataSource1.Fil l..... I think you need
SqlDataAdapter. Fill(ds)
"Bill" wrote:
This is probably easy but I cannot find it...

All I want to do is read the data out of a SQLDataSource programmaticall y 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

So, can this be done or do I need to create a hidden gridview to receive the
data?

Thanks

Bill
Aug 25 '06 #3
Thanks for the suggestions but I was looking for a way to use the
SQLDataSource control to reduce coding, not using the usual SQL objects.

I did find an answer so here it is:

Dim DV As New DataView

Dim xx As New DataSourceSelec tArguments

' get records into dataview

DV = SqlDataSource1. Select(xx.Empty )

' if no active messages then hide link

If DV.Count < 1 Then HyperLink1.Visi ble = False

Note that the above is ALL of the code needed since I am using the GUI
connection component & wizard to create the connection and string as the
control SQLDataSource1

Bill

"RJ" <RJ@discussions .microsoft.comw rote in message
news:DB******** *************** ***********@mic rosoft.com...
>I agree with using "Select Count(*)" with a cmd.executeScal er.

But, In your example with DataSource1.Fil l..... I think you need
SqlDataAdapter. Fill(ds)
"Bill" wrote:
>This is probably easy but I cannot find it...

All I want to do is read the data out of a SQLDataSource programmaticall y
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

So, can this be done or do I need to create a hidden gridview to receive
the
data?

Thanks

Bill

Aug 25 '06 #4

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

Similar topics

0
1239
by: kurt.craver | last post by:
I have a component control that I created as a UserControl which contains a SqlDataSource control, a GridView control, a DropDownList control, a TextBox control, and a Button control. The idea is that the user can select a column from the DropDownList, enter some text to search on in that column, and click the Button to perform the search. Then only the records matching the search criteria for that column will be displayed. The search...
0
1039
by: Sam | last post by:
Folks, I am new to ASP.Net 2.0. I do not know what I did with my configuration settings... Now when I drag and drop Sqldatasource from the toolbox, I can't see it in the design view. Even it disappeared from my existing forms... However when I swtched to source view, that referrence to Sqldatasource
9
2224
by: Dan Sikorsky | last post by:
When I hit the Test Query button in the SqlDataSource design, all the rows come back. But when I run the website, without any changes, in the IDE, the GridView tied to the SqlDataSoure is empty. How do I get this working? -- Thank you kindly, Dan Sikorsky BA, BSCE, MCS
3
5160
by: mahajanvit | last post by:
Hi one and all I got this problem during my project. So in order to solve this I made a very small application. I am trying to insert using SP and sqldatasource control. I know that while using sqldatasource control, there is no need of opening and closing a connection. Also there is no need to write connection string. When i am selecting table from sqldatasource and writing insert statement in C# code, its working fine. When I am...
5
7688
by: msch-prv | last post by:
Hi, I am trying to tie a SQLDataSource control to MySQL without success. The connection string works ok with an ObjectDataSource. (Native asp.net 2.0 MySQL dll loaded in /bin) For some reason, the compiler believes an SQL db is being accessed ("An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does...
1
5769
by: John Kotuby | last post by:
Hello again... I have tried using the SQLDatsource control as part of a user control that just conatins a Repeater and the SQLDatasource control which is designated as the Datsource for the Repeater. I set it up just like in the documentation. --------------------------- code ---------------------------------------- <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
1
6134
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some label,textboxs,dropdownlists,radiobutton and checkbox asp standard controls. On the click event of the command button the data gets stored into the database. I have created the stored procedures for the insert,update,delete. I have...
7
2890
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM", "OE_HDR"."SLS_MAN_NO", "OE_HDR"."SLS_MAN_INITIALS", "OE_HDR"."ORD_DAT", "OE_HDR"."SHIP_DAT" FROM "OE_HDR" WHERE ("OE_HDR"."ORD_NO"='174310') I also have DropDownList1 working properly. For the WHERE portion of
6
1885
by: tshad | last post by:
I was looking at a page that showed how to set up a custom event and it seems to work ok. But I am not sure how I would use it. How would I subscribe to it. There is actual action (such as pressing a button or changing text in a textbox). It gets set up and on the user control on my web page I can see the event from intellisense. So it seems to be set up, but I am trying to get an easy example of how I would now use this event. ...
0
10330
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10153
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
10093
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
9952
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
8976
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
7500
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
6740
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
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...
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.