Simple asp.net question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am new to asp.net and am having a hard time with what i would usually do
with a recordset. I have a simple query that returns a record - how can i
get that record value into a variable after i execute the query:

select Max(DailyPOnumber) + 1 as MaxPO from tblPurchaseOrders

i used to be able to do something similar to
MaxNo=rs("MaxNo")

any help would be appreciated
 
Thank You for your help - this got me a little further.

I Dimensioned maxno as an objext

i tried making it an integer and it errored out. The problem is now that it
is an object i am not able to work with the value - i tried assigning it to a
text box and i got the following error:

Exception Details: System.InvalidCastException: Cast from type
'SqlDataReader' to type 'String' is not valid.

Source Error:


Line 238: End If
Line 239: Label11.Text = Sql
Line 240: lblextra.Text = MaxPO <-----Problem line
Line 241: End Sub
Line 242:End Class
 
My ongoing saga to return a value from a stored procedure - i switched from
using data reader to using a dataadapter. I now am able to assign a textbox
the number of records returned by the Stored procedure with:

txtExtra.Text = DS.Tables("PO").Rows.Count
it returns 1 which is what i expect - i want to actually store the value of
the stored procedure returns (it is a simple SQL - Select Max(po) from PODB)

i tried the following line and it returns nothing:
txtExtra.Text = DS.Tables("PO").Rows(0).Item(0).ToString()

i tried
txtExtra.Text = DS.Tables("PO").Rows(1).Item(1).ToString()
and i get an error which tells me there is now row 1.

Any help would be greatly appreciated - it is frustrating - i feel i am
very close yet so far away....
 
Back
Top