SQL get count(*) from items... no rows returned error

P

Pikarde

I made a search page that will display items matching the users input.
It will display 8 items per page. So paging is a must.
I'm migrating the page from asp to asp.net

in asp it's very easy to call an sql statement as followed " select
count(*) as allitems from items where sku=' " & request.form("search") & "'
"
i then retireve allitems in a recordset and have the number of rows from
that searchresult.

When I do the same in ASP.Net i get the error message that no rows have been
returned.
it doesnt seem to recognize the 'allitems' . every other query against the
DB works, like sku, description, price and so on...
I execute a regular select query against an Access database through OleDB.

If I bind "allitems" to a usercontrol/textbox it works perfectly fine.

But I need the info before the page displays so I can create the paging
mechanism.

Can anyone please help?
Thanks in advance







webmaster AT pikarde DOT com
 
E

Elizabeth Harmon

with out seeing code, it's diffult to answer but i am assuming you are Using
ExecuteNonQuery? and not getting anything?

Try using ExecuteScalar() like this
yourvariable = Command.executeScalar()

then your variable should contain your count

Hope this helps
Samantha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top