Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / October 2004

Tip: Looking for answers? Try searching our database.

Simple asp.net question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PCL - 27 Oct 2004 22:17 GMT
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
[Alan Flores] - 27 Oct 2004 22:33 GMT
try this :

on the datareader
do while reader.read
maxno = reader("maxno")
loop

--

> 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
[quoted text clipped - 6 lines]
>
> any help would be appreciated
PCL - 27 Oct 2004 22:49 GMT
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


> try this :
>
[quoted text clipped - 15 lines]
> >
> > any help would be appreciated
Hermit Dave - 28 Oct 2004 00:00 GMT
try MaxPo.ToString();
or convert.ToString(MaxPO);

Signature

Regards,

Hermit Dave (D'way)
http://hdave.blogspot.com

(I hear what you're saying.. but lets try it my way first)

> Thank You for your help - this got me a little further.
>
[quoted text clipped - 34 lines]
> > >
> > > any help would be appreciated
PCL - 28 Oct 2004 14:55 GMT
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....

> try MaxPo.ToString();
> or convert.ToString(MaxPO);
[quoted text clipped - 41 lines]
> > > >
> > > > any help would be appreciated

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.