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

  • Thread starter Thread starter Pikarde
  • Start date Start date
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
 
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
 
Back
Top