Using SQLDataSource without a control?

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

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
 
I agree with using "Select Count(*)" with a cmd.executeScaler.

But, In your example with DataSource1.Fill..... I think you need
SqlDataAdapter.Fill(ds)
 
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
 
Back
Top