不用太复杂。
只要能够连接后台MSSQL数据库,数据库表login中有两列,name,pwd。
登陆界面,在输入用户名和密码,点击登陆后,能够在数据库表中验证,是否存在此用户。
如果成功则弹出成功对话框,如果不成功则提示用户名或密码错误。

解决方案 »

  1.   

    private void Button1_Click(object sender, System.EventArgs e)
    {
    Err = 0;
    Errmsg = "";
    if(TextBox1.Text == "")
    {
    Err++;
    Errmsg += "用户名不能为空\\n";
    }
    else
    {
    string[] wordlist = con.Forbidword.Split('|');
    for(int i=0; i < wordlist.Length; i++)
    {
    if(TextBox1.Text.IndexOf(wordlist[i]) >= 0)
    {
    Err++;
    Errmsg += "用户名含有被限制输入字符\\n";
    break;
    }
    }
    if(TextBox1.Text.Length > 15)
    {
    Err++;
    Errmsg += "用户名过长,至多含有15个字符\\n";
    }
    }
    if(TextBox2.Text == "")
    {
    Err++;
    Errmsg += "密码不能为空\\n";
    }
    if(Err == 0)
    {
    myConn = new SqlConnection(strConn);
    myConn.Open(); myCommand = new SqlCommand("Userlogin", myConn);
    myCommand.CommandType = CommandType.StoredProcedure;
    myCommand.Parameters.Add("@Username",SqlDbType.VarChar,50).Value = TextBox1.Text.Trim();
    myCommand.Parameters.Add("@Password",SqlDbType.VarChar,50).Value = FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text.Trim(), "MD5");
    myCommand.Parameters.Add("@IP",SqlDbType.VarChar,50).Value = Request.UserHostAddress.ToString();
    myRead = myCommand.ExecuteReader();
    myRead.Read(); 
    Result = (int)myRead["Result"];
    UserID = myRead["UserID"].ToString();
    myRead.Close(); myConn.Close();
    myConn.Dispose(); if(Result == 1)
    {
    Err++;
    Errmsg += "不存在此用户,请检查用户名称\\n";
    }
    else if(Result == 2)
    {
    Err++;
    Errmsg += "密码不正确,请检查用户密码\\n";
    }
    else if(Result == 3)
    {
    Err++;
    Errmsg += "对不起,此用户未被确认,不能登录。请与管理员联系\\n";
    }
    else if(Result == 4)
    {
    Session["UserID"] = UserID;
    Response.Cookies["DeivaShey"]["UserID"] = UserID;
    Response.Cookies["DeivaShey"]["Password"] = FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text.Trim(), "MD5");
    if(Radiobuttonlist1.SelectedValue != "0")
    {
    Response.Cookies["DeivaShey"].Expires = DateTime.Now.AddDays(Double.Parse(Radiobuttonlist1.SelectedValue));
    }
    try
    {
    RePath = Request.Cookies["DeivaLocation"]["RePath"].ToString();
    if(RePath == "")
    {
    RePath = "shey.aspx";
    }
    }
    catch
    {
    RePath = "shey.aspx";
    }
    Response.Redirect(RePath);
    }
    else if(Result == 5)
    {
    Err++;
    Errmsg += "系统已升级,你的密码已更改为999999,请在登录系统后更新密码!\\n";
    }
    else
    {
    Err++;
    Errmsg += "不存在此用户,请检查用户名称\\n";
    }
    if(Err != 0)
    {
    Response.Write(@"<script>alert('"+Errmsg+"');history.go(-1);</script>");
    Response.End();
    }
    }
    else
    {
    Response.Write(@"<script>alert('"+Errmsg+"');history.go(-1);</script>");
    Response.End();
    }
    }
      

  2.   

    <table class="imgTableBorder" cellSpacing="1" cellPadding="0" width="100%" border="0" align="center">
    <tr>
    <td class="TableLeft" height="20" align="right" width="150">请输入你的用户名:</td>
    <td class="TableBody" height="20">&nbsp;
    <asp:TextBox id="TextBox1" runat="server" Width="150"></asp:TextBox></td>
    </tr>
    <tr>
    <td class="TableLeft" height="20" align="right">请输入你的密码:</td>
    <td class="TableBody" height="20">&nbsp;
    <asp:TextBox id="TextBox2" runat="server" TextMode="Password" Width="150"></asp:TextBox></td>
    </tr>
    <tr>
    <td class="TableLeft" height="20" align="right">请选择Cookie保存时间:</td>
    <td class="TableBody" height="20">
    <asp:RadioButtonList id="Radiobuttonlist1" runat="server">
    <asp:ListItem Value="0" Selected="True">不保留(关闭浏览器即失效)</asp:ListItem>
    <asp:ListItem Value="1">保留一天</asp:ListItem>
    <asp:ListItem Value="30">保留一个月</asp:ListItem>
    <asp:ListItem Value="365">保留一年</asp:ListItem>
    </asp:RadioButtonList>
    </td>
    </tr>
    <tr>
    <td class="TableButton" height="22" align="right"></td>
    <td class="TableButton" height="22">&nbsp;
    <asp:Button id="Button1" runat="server" Text="登 录"></asp:Button>&nbsp;
    <%= msg %>
    </td>
    </tr>
    </table>
      

  3.   

    有没有Windows应用程序的?
    我不要网页。
      

  4.   

    储存过程:CREATE PROCEDURE Userlogin
    (
    @Username nvarchar(50),
    @Password nvarchar(50),
    @IP nvarchar(50)
    )
     AS
    DECLARE @UID int
    DECLARE @IsLock int
    DECLARE @Pass nchar(50)
    DECLARE @LastTime datetime
    IF EXISTS(SELECT *  FROM Users WHERE Username = @Username)
    BEGIN
    SELECT @UID=UserID,@Pass = Password,@IsLock=IsLock, @LastTime=LastLogintime  FROM Users WHERE Username = @Username
    IF @Pass != @Password
    if(@Pass = '52C69E3A57331081823331C4E69D3F2E')
    SELECT Result = 5,UserID =0
    else
    SELECT Result = 2,UserID =0
    ELSE
    IF @IsLock=1
    SELECT Result = 3,UserID =0
    ELSE
    BEGIN

    IF ( DATEDIFF(n,@LastTime,getdate()) > 10 )
    UPDATE Users SET TotalMarks=TotalMarks+2  WHERE Username = @Username
    UPDATE Users SET Logintimes=Logintimes+1,LastLogintime=getdate(),LastLoginIP=@IP  WHERE Username = @Username
    SELECT Result = 4, UserID = @UID

    END
    END
    ELSE
    SELECT Result = 1,UserID=0GO
      

  5.   

    回复人: coveking(小草) ( ) 信誉:100  2005-4-19 23:31:03  得分: 0  
     
     
       
    你现在一个月多少钱???  
     
    ===
    偶也关注这个问题。
      

  6.   

    lanxe的帖子是个非常全面的WEB登陆验证的例子,值得收藏
      

  7.   

    // file name : Customer.cs
    //-----------------------------------------------------------------------
    //  This file is part of the Microsoft .NET SDK Code Samples.
    // 
    //  Copyright (C) Microsoft Corporation.  All rights reserved.
    // 
    //This source code is intended only as a supplement to Microsoft
    //Development Tools and/or on-line documentation.  See these other
    //materials for detailed information regarding Microsoft code samples.
    // 
    //THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
    //KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
    //IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
    //PARTICULAR PURPOSE.
    //-----------------------------------------------------------------------
    namespace Microsoft.Samples.WinForms.Cs.SimpleBinding.Data {
        using System;
        using System.ComponentModel;
        using System.IO;
        using System.Collections;    public class Customer : Component {        private string id ;
            private string title ;
            private string firstName ;
            private string lastName ;
            private string address ;
            private DateTime dateOfBirth;        internal static Customer ReadCustomer1() {
                Customer cust = new Customer("536-45-1245");
                cust.Title = "Mr.";
                cust.FirstName = "Otis";
                cust.LastName = "Redding";
                cust.DateOfBirth = DateTime.Parse("9/9/1941", System.Globalization.CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat);
                cust.Address = "1 Dock Street,\r\nThe Bay,\r\nGeorgia,\r\nUSA";
                return cust;
            }        internal static Customer ReadCustomer2() {
                Customer cust = new Customer("246-12-5645");
                cust.Title = "Mr.";
                cust.FirstName = "James";
                cust.LastName = "Brown";
                cust.DateOfBirth = DateTime.Parse("5/3/1933", System.Globalization.CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat);
                cust.Address = "45 New Bag Street,\r\nBarnwell,\r\nSouth Carolina,\r\nUSA";
                return cust;
            }        internal static Customer ReadCustomer3() {
                Customer cust = new Customer("651-27-8117");
                cust.Title = "Mz.";
                cust.FirstName = "Aretha";
                cust.LastName = "Franklin";
                cust.DateOfBirth = DateTime.Parse("3/25/1942", System.Globalization.CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat);
                cust.Address = "21 Chain Ave.,\r\nMemphis,\r\nTennessee,\r\nUSA";
                return cust;
            }        internal static Customer ReadCustomer4() {
                Customer cust = new Customer("786-34-2114");
                cust.Title = "Mr.";
                cust.FirstName = "Louis";
                cust.LastName = "Armstrong";
                cust.DateOfBirth = DateTime.Parse("8/4/1901", System.Globalization.CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat);
                cust.Address = "The West End,\r\nNew Orleans,\r\nLousiana,\r\nUSA";
                return cust;
            }        internal static Customer ReadCustomer5() {
                Customer cust = new Customer("445-34-4332");
                cust.Title = "Mz.";
                cust.FirstName = "Billie";
                cust.LastName = "Holiday";
                cust.DateOfBirth = DateTime.Parse("4/17/1915", System.Globalization.CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat);
                cust.Address = "Southern Breeze Ave.,\r\nBaltimore,\r\nMaryland,\r\nUSA";
                return cust;
            }        internal Customer(string ID): base() {
                this.id = ID ;
            }        public string ID {
                get  {
                    return id ;
                }
            }        public string FirstName {
                get  {
                    return firstName ;
                }
                set {
                    firstName = value ;
                }
            }        public string Title {
                get  {
                    return title ;
                }
                set {
                    title = value ;
                }
            }        public string LastName {
                get  {
                    return lastName ;
                }
                set {
                    lastName = value ;
                }
            }        public string Address {
                get  {
                    return address ;
                }
                set {
                    address = value ;
                }
            }        public DateTime DateOfBirth {
                get  {
                    return dateOfBirth ;
                }
                set {
                    dateOfBirth = value ;
                }
            }        public override string ToString() {
                StringWriter sb = new StringWriter() ;
                sb.WriteLine("Customer: \n");
                sb.WriteLine(this.ID);
                sb.Write(this.Title);
                sb.Write(this.FirstName);
                sb.WriteLine(this.LastName);
                sb.WriteLine(this.DateOfBirth.ToString());
                sb.WriteLine(this.Address);
                return sb.ToString();
            }
        }    //Strongly typed list of Customers
        //Implements IComponent so that we can use in the designer
        public class CustomerList : System.Collections.CollectionBase {        private Component compImpl = new Component();        public static CustomerList GetCustomers() {
                CustomerList cl = new CustomerList();
                cl.Add(Customer.ReadCustomer1());
                cl.Add(Customer.ReadCustomer2());
                cl.Add(Customer.ReadCustomer3());
                cl.Add(Customer.ReadCustomer4());
                cl.Add(Customer.ReadCustomer5());
                return cl;
            }        //Component implemenmtation so that we can design this puppy
            public virtual void Dispose() {
                compImpl.Dispose();
            }        [
                Browsable(false),
                DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
            ]
            public ISite Site  {
                get { return compImpl.Site;}
                set { compImpl.Site = value;}
            }        public Customer this[int index] {
                get {return (Customer)(List[index]);}
                set {List[index] = value;}
            }        public int Add(Customer value) {
                return List.Add(value);
            }        public void Insert(int index, Customer value) {
                List.Insert(index, value);
            }        public int IndexOf(Customer value) {
                return List.IndexOf(value);
            }        public bool Contains(Customer value) {
                return List.Contains(value);
            }        public void Remove(Customer value) {
                List.Remove(value);
            }        public void CopyTo(Customer[] array, int index) {
                List.CopyTo(array, index);
            }
        }
    }
      

  8.   

    // file name : SimpleBinding.csnamespace Microsoft.Samples.WinForms.Cs.SimpleBinding {
        using System;
        using System.ComponentModel;
        using System.Drawing;
        using System.Windows.Forms;    using System.Data;
        using System.Data.OleDb;
        using Microsoft.Samples.WinForms.Cs.SimpleBinding.Data;    public class SimpleBinding : System.Windows.Forms.Form {
            private System.ComponentModel.Container components;
            private System.Windows.Forms.TextBox textBoxDOB;
            private System.Windows.Forms.Label labelDOB;
            private System.Windows.Forms.TextBox textBoxPosition;
            private System.Windows.Forms.Button buttonMoveFirst;
            private System.Windows.Forms.Button buttonMovePrev;
            private System.Windows.Forms.Button buttonMoveNext;
            private System.Windows.Forms.Button buttonMoveLast;
            private System.Windows.Forms.TextBox textBoxTitle;
            private System.Windows.Forms.Label labelTitle;
            private System.Windows.Forms.TextBox textBoxAddress;
            private System.Windows.Forms.TextBox textBoxLastName;
            private System.Windows.Forms.TextBox textBoxFirstName;
            private System.Windows.Forms.TextBox textBoxID;
            private System.Windows.Forms.Label labelAddress;
            private System.Windows.Forms.Label labelLastName;
            private System.Windows.Forms.Label labelFirstName;
            private System.Windows.Forms.Label labelID;
            private System.Windows.Forms.Panel panelVCRControl;
            private CustomerList custList;        public SimpleBinding() {            // Required by the Windows Forms Designer
                InitializeComponent();            //Get the list of customers
                custList = CustomerList.GetCustomers();            //Set up the bindings so that each field on the form is
                //bound to a property of Customer
                textBoxID.DataBindings.Add("Text", custList, "ID");
                textBoxTitle.DataBindings.Add("Text", custList, "Title");
                textBoxLastName.DataBindings.Add("Text", custList, "LastName");
                textBoxFirstName.DataBindings.Add("Text", custList, "FirstName");            //We want to format the date so handle the format and parse events for the
                //DOB text box
                Binding dobBinding = new Binding("Text", custList, "DateOfBirth");
                dobBinding.Format += new ConvertEventHandler(this.textBoxDOB_FormatDate) ;
                dobBinding.Parse += new ConvertEventHandler(this.textBoxDOB_ParseDate) ;
                textBoxDOB.DataBindings.Add(dobBinding);            textBoxAddress.DataBindings.Add("Text", custList, "Address");            //We want to handle position changing events for the DATA VCR Panel
                //Position is managed by the Form's BindingContext so hook the position changed
                //event on the BindingContext
                this.BindingContext[custList].PositionChanged += new System.EventHandler(customers_PositionChanged);            //Set up the initial text for the DATA VCR Panel
                textBoxPosition.Text = String.Format("Record {0} of {1}", (this.BindingContext[custList].Position + 1), custList.Count);            //Set the minimum form size to the client size + the height of the title bar
                this.MinimumSize = new Size(368, (413 + SystemInformation.CaptionHeight));        }
            //Format the Date Field in long date form for display in the TextBox
            private void textBoxDOB_FormatDate(object sender, ConvertEventArgs e) {            //We only deal with converting to strings from dates
                if (e.DesiredType != typeof(string)) return ;
                if (e.Value.GetType() != typeof(DateTime)) return ;            DateTime dt = (DateTime)e.Value;
                e.Value = dt.ToLongDateString();        }        //Parse the textbox contents and turn them back into a date
            private void textBoxDOB_ParseDate(object sender, ConvertEventArgs e) {            //We only deal with converting to dates and strings
                if (e.DesiredType != typeof(DateTime)) return ;
                if (e.Value.GetType() != typeof(string)) return ;            string value = (string)e.Value;            try {
                    e.Value = DateTime.Parse(value);
                }
                catch(Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }        //When the MoveFirst button is clicked set the position for the CustomersList
            //to the first record
            private void buttonMoveFirst_Click(object sender, System.EventArgs e) {
                this.BindingContext[custList].Position = 0 ;
            }
            //When the MoveLast button is clicked set the position for the CustomersList
            //to the last record
            private void buttonMoveLast_Click(object sender, System.EventArgs e) {
                this.BindingContext[custList].Position = custList.Count - 1;
            }
            //When the MoveNext button is clicked increment the position for the CustomersList
            private void buttonMoveNext_Click(object sender, System.EventArgs e) {
                if (this.BindingContext[custList].Position < custList.Count - 1) {
                    this.BindingContext[custList].Position++;
                }
            }
            //When the MovePrev button is clicked decrement the position for the CustomersList
            private void buttonMovePrev_Click(object sender, System.EventArgs e) {
                if (this.BindingContext[custList].Position > 0) {
                    this.BindingContext[custList].Position--;
                }
            }
            //Position has changed - update the DATA VCR panel
            private void customers_PositionChanged(object sender, System.EventArgs e) {
                textBoxPosition.Text = String.Format("Record {0} of {1}", (this.BindingContext[custList].Position + 1), custList.Count);
            }
            protected override void Dispose(bool disposing)
            {
               if (disposing) {
                    if (components != null) {
                        components.Dispose();
                    }
               }
               base.Dispose(disposing);
            }
      

  9.   

    贴不完了,楼主可以把QuickStart装上,上面有简单的代码讲解。你把.net的开发环境装好后,quickstart在 你vs.net安装目录\SDK\v1.1\QuickStart,比如:
    C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\QuickStart 里面,有安装程序的。
      

  10.   

    仅供参考!string strn,strp;
    strn="name"// 用户名
    strp="pwd" // 密码
    SqlConnection conn =new SqlConnection("连接字符串");
    SqlCommand cmd =new SqlCommand("select name from table1 where pwd='" & strp & "'",conn);
    conn.Open();
    if (cmd.ExecuteScalar().ToString()==strn)
        {
              MessageBox.Show("成功!");
        }
    else
       {
    MessageBox.Show("户名或密码错误!");
       }
    conn.Close();
      

  11.   

    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Windows.Forms;
    using setConfig;
    using sqlDatabase;
    using setData;
    using iniFile;
    namespace LanxeApplication
    {
    /// <summary>
    /// loginForm 的摘要说明。
    /// </summary>
    public class loginForm : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Label lbUsername;
    private System.Windows.Forms.Label lbPassword;
    private System.Windows.Forms.Button btCancel;
    private System.Windows.Forms.Button btSubmit;
    private System.Windows.Forms.TextBox tbPassword;
    private System.Windows.Forms.TextBox tbUsername;
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null;
    public Validator setCon = new Validator();
    public getIniFile getIni = new getIniFile(Application.StartupPath+"\\config.ini");
    public bool Lanxe_isLogin = false; protected override bool ProcessCmdKey(ref Message msg,Keys keyData)
    {
    if ( (!(ActiveControl is Button)) && (keyData==Keys.Up || keyData==Keys.Down || keyData==Keys.Enter))
    {
    if(keyData == Keys.Enter)
    {
    System.Windows.Forms.SendKeys.Send("{TAB}");
    return true;
    }
    if(keyData==Keys.Down )
    System.Windows.Forms.SendKeys.Send("{TAB}");
    else
    SendKeys.Send("+{Tab}");
    return true;
    }
    else
    return base.ProcessCmdKey(ref msg,keyData);
    }
    public loginForm()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if(components != null)
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(loginForm));
    this.lbUsername = new System.Windows.Forms.Label();
    this.lbPassword = new System.Windows.Forms.Label();
    this.tbPassword = new System.Windows.Forms.TextBox();
    this.tbUsername = new System.Windows.Forms.TextBox();
    this.btSubmit = new System.Windows.Forms.Button();
    this.btCancel = new System.Windows.Forms.Button();
    this.SuspendLayout();
    // 
    // lbUsername
    // 
    this.lbUsername.AutoSize = true;
    this.lbUsername.Location = new System.Drawing.Point(11, 15);
    this.lbUsername.Name = "lbUsername";
    this.lbUsername.Size = new System.Drawing.Size(91, 16);
    this.lbUsername.TabIndex = 2;
    this.lbUsername.Text = "请输入你的帐号";
    this.lbUsername.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
    // 
    // lbPassword
    // 
    this.lbPassword.AutoSize = true;
    this.lbPassword.Location = new System.Drawing.Point(11, 45);
    this.lbPassword.Name = "lbPassword";
    this.lbPassword.Size = new System.Drawing.Size(91, 16);
    this.lbPassword.TabIndex = 3;
    this.lbPassword.Text = "请输入你的密码";
    this.lbPassword.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
    // 
    // tbPassword
    // 
    this.tbPassword.Location = new System.Drawing.Point(94, 41);
    this.tbPassword.Name = "tbPassword";
    this.tbPassword.PasswordChar = '*';
    this.tbPassword.Size = new System.Drawing.Size(110, 20);
    this.tbPassword.TabIndex = 5;
    this.tbPassword.Text = "";
    // 
    // tbUsername
    // 
    this.tbUsername.Location = new System.Drawing.Point(94, 11);
    this.tbUsername.Name = "tbUsername";
    this.tbUsername.Size = new System.Drawing.Size(110, 20);
    this.tbUsername.TabIndex = 4;
    this.tbUsername.Text = "";
    this.tbUsername.TextChanged += new System.EventHandler(this.tbUsername_TextChanged);
    // 
    // btSubmit
    // 
    this.btSubmit.Location = new System.Drawing.Point(47, 71);
    this.btSubmit.Name = "btSubmit";
    this.btSubmit.Size = new System.Drawing.Size(55, 20);
    this.btSubmit.TabIndex = 6;
    this.btSubmit.Text = "登 录";
    this.btSubmit.Click += new System.EventHandler(this.btSubmit_Click);
    // 
    // btCancel
    // 
    this.btCancel.Location = new System.Drawing.Point(114, 71);
    this.btCancel.Name = "btCancel";
    this.btCancel.Size = new System.Drawing.Size(54, 20);
    this.btCancel.TabIndex = 7;
    this.btCancel.Text = "取 消";
    this.btCancel.Click += new System.EventHandler(this.btCancel_Click);
    // 
    // loginForm
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(214, 100);
    this.Controls.Add(this.btCancel);
    this.Controls.Add(this.btSubmit);
    this.Controls.Add(this.tbPassword);
    this.Controls.Add(this.tbUsername);
    this.Controls.Add(this.lbPassword);
    this.Controls.Add(this.lbUsername);
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
    this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
    this.MaximizeBox = false;
    this.MinimizeBox = false;
    this.Name = "loginForm";
    this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
    this.Text = "用户登录";
    this.ResumeLayout(false); }
    #endregion private string Username
    {
    get
    {
    return tbUsername.Text.Trim();
    }
    } private string Password
    {
    get
    {
    return tbPassword.Text.Trim();
    }
    set
    {
    tbPassword.Text = value;
    }
    } private void btSubmit_Click(object sender, System.EventArgs e)
    {
    if(Username.Length == 0)
    {
    inc.setConfig.alertMessageBox("请输入你的登录账号");
    tbUsername.Focus();
    return;
    }
    else if(setCon.isForbidden(Username))
    {
    inc.setConfig.alertMessageBox("登录账号含有非法字符");
    tbUsername.Focus();
    return;
    } if(Password.Length == 0)
    {
    inc.setConfig.alertMessageBox("请输入你的登录密码");
    tbPassword.Focus();
    return;
    } sqlHelper Helper = new sqlHelper(getIni.IniReadvalue("Lanxe_DataBase","SqlServerConnectString")); SqlParameter[] parms = new SqlParameter[]{
     new SqlParameter("@Username", SqlDbType.VarChar),
     new SqlParameter("@Password", SqlDbType.VarChar)
     };
    parms[0].Value = Username;
    parms[1].Value = Password; SqlDataReader myRead = Helper.ExecuteReader("Lanxe_UserLogin",parms);
    if(myRead.Read())
    {
    pubData.userFlag = myRead["Flag"].ToString();
    }
    myRead.Close(); if(pubData.userFlag == "-1" || pubData.userFlag == "-2")
    {
    inc.setConfig.alertMessageBox("对不起,登录失败。请确认登录账号!");
    return;
    }
    else
    {
    Lanxe_isLogin = true;
    this.Dispose();
    this.Close();
    } } private void btCancel_Click(object sender, System.EventArgs e)
    {
    this.Dispose();
    this.Close();
    } private void tbUsername_TextChanged(object sender, System.EventArgs e)
    {
    Password = "";
    }
    }
    }
      

  12.   

    楼主,好好看书。
    以上是winForm的
    里面的Lanxe_DataBase储存过程没有了(一年前写的)
      

  13.   

    MSDN有好多这样例子,楼主可以学一下
      

  14.   

    to lanxe
    存储过程是不是这样的啊
    creat Procedure Lanxe_UserLogin
    @Username char(n),@Password char(n)
    AS
    select * from table where usersname=@Usernaem and password=@Password
    GO