当前位置:编程学习 > C#/ASP.NET >>

求助了 用SESSION提取登陆帐号出错

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Xml;
using System.Web;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public static XmlDocument MydocLoginMessage = new XmlDocument();
        
        public static string trsid ;
        public Form1()
        {
            InitializeComponent();

        }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (Session["PaperID"] != null)
                Session["Name"] = "value(Or Object)";
           
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {

            Close();

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection SqlDrConn = new SqlConnection("Server=sa;Database=dbo.Wage;Integrated Security=True");
            SqlDrConn.Open();
            SqlCommand cmd = SqlDrConn.CreateCommand();
            cmd.CommandText = "select * from Wage where id='" + textBox1.Text + "'and psw='" + textBox2.Text + "'";//textbox1,2分别为用户名和密码
            DataSet ds = new DataSet();
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            sda.Fill(ds);
            if (ds.Tables[0].Rows.Count > 0)
            {
                Form2 form = new Form2();
                form.ShowDialog();
                this.Close();  
            }
            else
            {
                MessageBox.Show("对不起,您的密码不正确");

            }
        }
    }

}







提示错误当前上下文中不存在名称“Session” --------------------编程问答-------------------- 你这是winform程序,不是web程序,session是web程序下的 --------------------编程问答-------------------- 那我该用什么来传递登陆帐号、
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,