Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: session answer


Message #1 by "haley" <88sohu@1...> on Mon, 3 Jun 2002 04:24:32
Try this:

Replace the line:
---
ParameterSessionName.Value=Session("Name")
---
with
---
ParameterSessionName.Value = System.Web.HttpContext.Current.Session("Name")
---

	You might have to do a cast from object to string (in C# we merely
put "(string)" before the variable to cast) using that funky VB function to
do it (Session collection returns object and .Value of SqlParameter is
probably string).

HTH,
- Chuck

-----Original Message-----
From: haley [mailto:88sohu@1...]
Sent: Monday, June 03, 2002 12:25 AM
To: ASPX_Professional
Subject: [aspx_professional] session answer


Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
 
NameSpace Bbs
Public Class GetBbs
 
Public Function GetMyanswer() as SqlDataReader
Dim MyConnection as new sqlConnection(ConfigurationSettings.AppSettings
("StrConnection"))
Dim MyCommand as New sqlCommand("Myanswer",MyConnection)
MyCommand.CommandType=CommandType.StoredProcedure
Dim ParameterSessionName as New sqlParameter("@SessionName",sqlDbType.char)
ParameterSessionName.Value=Session("Name")
MyCommand.Parameters.Add(ParameterSessionName)
MyConnection.Open()
Dim Result as SqlDataReader =MyCommand.ExecuteReader
(CommandBehavior.CloseConnection)
Return Result
End Function
End Class
 
End Namespace

 
wrong Message: Name 'session' is not declared.
 
Thank you very much!
 

  Return to Index