HELP... returning variable

G

Guest

Can someone please help... I'm kind of new to asp.net and VS.net and need to
know how to get the value of a variable in the following funtion into a sub
on another aspx page!

Can someone please help!

Thanks

...CODE..
Public Function GetOfficeName() As String
Dim Myconn As New
SqlConnection(ConfigurationSettings.AppSettings("strConn"))
Dim cmd As New SqlCommand("UserDetails", Myconn)
cmd.CommandType = CommandType.StoredProcedure

Myconn.Open()

Dim objParam1 As SqlParameter
objParam1 = cmd.Parameters.Add("@UserName", SqlDbType.Char)
objParam1.Direction = ParameterDirection.Input
objParam1.Value = Page.User.Identity.Name

Dim myReader As SqlDataReader = cmd.ExecuteReader()
While myReader.Read()
If Page.User.Identity.Name <> "" Then
Return myReader("offName")
End If
End While
' always call Close when done reading.
myReader.Close()
' Close the connection when done with it.
Myconn.Close()

End Function
 
K

Kevin Spencer

Pages operate in compleetely separate memory spaces, and exist at different
times, due to the statelessness of HTTP.

To get data from one page to the next, therefore, there are several possible
ways:

1. QueryString
2. Form Post
3. Server.Transfer
4. Store in Application Cache
5. Store in Session
6. Windows Messaging
7. Store in database

That's all I could think of off the top of my head, but I hope you get the
idea.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
G

Guest

If I put this function into a user control how do I get it out of the user
control and into the aspx page?

Thanks
 
K

Kevin Spencer

If I put this function into a user control how do I get it out of the user
control and into the aspx page?

If I put a box in the back seat of my car, how do I get it out of the back
seat and into the car?

The User Control IS in the page...

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 

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,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top