日期:2014-05-19  浏览次数:20734 次

帮看一下登陆的代码 菜鸟求救
这句name=   name.Text.Trim();//提示说无法将类型 "string "隐式转换为 "System.Web.UI.WebControls.TextBox "   什么改呢

这句   myDr   =   DB.ExecuteReader(strsel);//提示说找不到类型或命名空间名称   “DB”什么改能


using   System;
using   System.Collections;
using   System.ComponentModel;
using   System.Data;
using   System.Drawing;
using   System.Web;
using   System.Web.SessionState;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.HtmlControls;
using   System.Data.SqlClient;


namespace   第n次
{
///   <summary>
///   WebForm1   的摘要说明。
///   </summary>
    public   class   WebForm1   :   System.Web.UI.Page
{
protected   System.Web.UI.WebControls.Label   Label1;
protected   System.Web.UI.WebControls.Button   Button1;
protected   System.Web.UI.WebControls.Button   Button2;
protected   System.Web.UI.WebControls.Label   Label2;
protected   System.Web.UI.WebControls.Label   Label4;
protected   System.Web.UI.WebControls.TextBox   name;
protected   System.Web.UI.WebControls.TextBox   Password;
protected   System.Data.DataSet   dataSet1;
protected   System.Web.UI.WebControls.Label   Label3;
               
private   void   Page_Load(object   sender,   System.EventArgs   e)
{      
//   在此处放置用户代码以初始化页面
}

#region   Web   窗体设计器生成的代码
private   void   Button2_Click(object   sender,   System.EventArgs   e)
    {
        Response.Redirect   ( "WebForm2.aspx ");
      }

private   void   Button1_Click(object   sender,   System.EventArgs   e)
        {
name=   name.Text.Trim();
Password   =   Password.Trim();
string   strsel   =   "select   name,Password   from   Info_userdata   where       name   =   ' "+@name+ " '   and   Password   =   ' "+@Password+ " ' ";
//string   strsel   =   "select   User_Name,User_Password   from   Info_userdata   where   name   =   ' "+@name+ " ' ";
                       
SqlDataReader   myDr;
myDr   =   DB.ExecuteReader(strsel)
              if(myDr.Read())
              {                  
                  this.Visible=false;
                  Response.Redirect   ( "WebForm3.aspx ");


                }
          else
            {
                  Response.Write(Label4);