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”
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”
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货