如何使用cookies,dataview,sqldatasource登录?
Code
1Protected Sub ImgOK_Click()Sub ImgOK_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImgOK.Click
2 Dim isok As Integer
3
4 dim sys as SqlDatasource("datasource=127,0.0.1;Initial Catalog=EIP;User ID=sa","")
5 sys.SelectCommand = "select * from member,depart where m_acc = @name and m_pwd= @pwd and member.d_id=depart.d_id"
6 sys.SelectParameters.Add("name", acc.Text)
7 sys.SelectParameters.Add("pwd", pwd.Text)
8
9 Dim dv As Data.DataView = sys.Select(New DataSourceSelectArguments)
10 isok = dv.Count
11 If isok = 0 Then
12 My.SysEIP.WebForm.CientMsgBox("用户名或密碼錯誤", Me)
13 Else
14 Response.Cookies("name").Value = dv.Table.Rows(0).Item("m_acc")
15 Response.Cookies("pwd").Value = dv.Table.Rows(0).Item("m_pwd")
16 Response.Cookies("m_id").Value = dv.Table.Rows(0).Item("m_id")
17 Response.Cookies("d_id").Value = dv.Table.Rows(0).Item("d_id")
18 Response.Cookies("d_name").Value = dv.Table.Rows(0).Item("d_name")
19
20 Response.Cookies("name").Expires = selectdate
21 Response.Cookies("pwd").Expires = selectdate
22 Response.Cookies("m_id").Expires = selectdate
23 Response.Cookies("d_id").Expires = selectdate
24 Response.Cookies("d_name").Expires = selectdate
25
26 If Session("Url") = Nothing Then
27 Response.Redirect("index4.aspx")
28 Else
29 Response.Redirect(Session("Url"))
30 End If
31 End If
32End Sub
33
1Protected Sub ImgOK_Click()Sub ImgOK_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImgOK.Click
2 Dim isok As Integer
3
4 dim sys as SqlDatasource("datasource=127,0.0.1;Initial Catalog=EIP;User ID=sa","")
5 sys.SelectCommand = "select * from member,depart where m_acc = @name and m_pwd= @pwd and member.d_id=depart.d_id"
6 sys.SelectParameters.Add("name", acc.Text)
7 sys.SelectParameters.Add("pwd", pwd.Text)
8
9 Dim dv As Data.DataView = sys.Select(New DataSourceSelectArguments)
10 isok = dv.Count
11 If isok = 0 Then
12 My.SysEIP.WebForm.CientMsgBox("用户名或密碼錯誤", Me)
13 Else
14 Response.Cookies("name").Value = dv.Table.Rows(0).Item("m_acc")
15 Response.Cookies("pwd").Value = dv.Table.Rows(0).Item("m_pwd")
16 Response.Cookies("m_id").Value = dv.Table.Rows(0).Item("m_id")
17 Response.Cookies("d_id").Value = dv.Table.Rows(0).Item("d_id")
18 Response.Cookies("d_name").Value = dv.Table.Rows(0).Item("d_name")
19
20 Response.Cookies("name").Expires = selectdate
21 Response.Cookies("pwd").Expires = selectdate
22 Response.Cookies("m_id").Expires = selectdate
23 Response.Cookies("d_id").Expires = selectdate
24 Response.Cookies("d_name").Expires = selectdate
25
26 If Session("Url") = Nothing Then
27 Response.Redirect("index4.aspx")
28 Else
29 Response.Redirect(Session("Url"))
30 End If
31 End If
32End Sub
33