vb后台创建SESSION问题
想在登陆成功的时候创建个SESSION,然后传到下一个页面,代码如下
Protected Sub sLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles sLogin.Click
Dim cmd As Data.SqlClient.SqlCommand
Dim rd As Data.SqlClient.SqlDataReader
Dim sql As String
Dim name As String
sql = "select passwd from userinfo where cname = ' " & TextBox1.Text & " ' "
cmd = New Data.SqlClient.SqlCommand(sql, connection)
rd = cmd.ExecuteReader
If (rd.HasRows = False) Then
MsgBox( "用户名不存在 ")
End If
If (rd.Read) Then
If (TextBox2.Text = rd.GetValue(0)) Then
Session[ "name "] = TextBox1.Text
Server.Transfer( "main.aspx ")
Response.Redirect( "main.aspx ")
Else
MsgBox( "密码错误 ")
End If
End If
End Sub
但是Session[ "name "] = TextBox1.Text这句话报错,提示说属性访问必须分配给属性或使用它的值,请问该怎么解决法
------解决方案--------------------断点跟踪一下,看看报错那行都有什么
------解决方案--------------------VB没有[]