Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show only first row from SP in DataList

Status
Not open for further replies.

ralphtrent

Programmer
Jun 2, 2003
958
US
Hi
I have a Stored Procedure that returns multiple rows. the only difference in the rows is one field. I only want to display the first row, is there a way to do that?

Thanks
 
Yes, there are many ways. One of which is to create a New DataTable that only contains the relevant row and use that as the DataSource for the DataList.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Why wouldnt you use SELECT TOP 1 * FROM table in your stored proc? and still use standard DataSource

or do you still need all rows for some reason?
 
I still need all the rows. each row has all the same data but one column. my intention was to save as many trips to the dataserver as possible. so neither of these suggestions will work for what i need to do.

ca8msm, what other options are there as you only list one, but say there are many?

Thanks
 
how are you implementing your datalist then? dont use a datalist if only one

Sub getData
get your datasource
textbox.text = ds.tables(0).Rows(0).Item("columnName")
'countinue to add any other column staticly
End Sub

or you can do two tables in your stored proc

CREATE Stored Procedure sp_StProc

SELECT TOP 1 * FROM table

SELECT * FROM table

GO

...

Sub getData
get your datasource
'databind your one row table
datalist.datasource = ds.tables(0)
datalist.databind()

'databind your other table to the thing you need
'using the same dataconnection
otherstuff.datasource = ds.table(1)
otherstuff.datatbind()
End Sub

post some examples to help us understand how to help you, how far did you get, where are you hung up in coding?
 
You could:

1) Create a DataView
2) Create your own object
3) Bind it to a seperate SP

Oh, and my previous suggestion wouldn't create a second trip to the database.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top