|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
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 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 So, can this be done or do I need to create a hidden gridview to receive the data? Thanks Bill "Bill" <a*@ss.com> wrote in Use a SQLCommand object... and execute a scalar command like "SELECT COUNTnews:4dmHg.8947$bZ6.7643@tornado.tampabay.rr.com: > All I want to do is read the data out of a SQLDataSource > programmatically to test if there are any records. (1) FROM TABLE" http://msdn2.microsoft.com/en- us/library/system.data.sqlclient.sqlcommand.executescalar.aspx I agree with using "Select Count(*)" with a cmd.executeScaler.
But, In your example with DataSource1.Fill..... I think you need SqlDataAdapter.Fill(ds) Show quoteHide quote "Bill" wrote: > 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 > > So, can this be done or do I need to create a hidden gridview to receive the > data? > > Thanks > > Bill > > > 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 DataSourceSelectArguments ' get records into dataview DV = SqlDataSource1.Select(xx.Empty) ' if no active messages then hide link If DV.Count < 1 Then HyperLink1.Visible = 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 Show quoteHide quote "RJ" <R*@discussions.microsoft.com> wrote in message news:DBAD8366-DF9B-43C5-80BD-05492CBD5BC3@microsoft.com... >I agree with using "Select Count(*)" with a cmd.executeScaler. > > But, In your example with DataSource1.Fill..... 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 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 >> >> So, can this be done or do I need to create a hidden gridview to receive >> the >> data? >> >> Thanks >> >> Bill >> >> >>
How to create a report (invoice)?
File operation with user-set wildcards Drag and Drop from Outlook to Vb.net RichTextBox Q: deleting relations Arrays please help me Where is the ENTIRE list of compile time error messages/numbers stored in vb/visual studi Copying my file to another location on the hard disk SFTP crystalreport with sql select Compile VB6 Code Runtime |
|||||||||||||||||||||||