本人是C#新手,近日遇到一关于“登陆”的问题,就是用VS2005做一个登录的窗体,大体思想是:先用SQL server建一个“用户信息”数据库,主要分“用户名”“用户类型”“密码”三列,然后和VS建立连接,当用户选择用户类型,并输入用户名和密码后,系统先是参照数据库,如果无误,点击OK,就可以进入。
   这个问题对于高手应该不难,还望不吝赐教,小弟将万分感激!!!

解决方案 »

  1.   

    http://www.51aspx.com
    这个上面有很多不错的列子,比较适合你。都是免费下的,你下下来研究一下就可以了。
      

  2.   

    //**********************************登陆操作**************************************
            private void button1_Click(object sender, EventArgs e)
            {
                SqlConnection thisConnection = new SqlConnection(@"server=PC-20100303NWFB;database=bacy;uid=sa;pwd=87936260");
                thisConnection.Open();
                SqlCommand thisCommand = thisConnection.CreateCommand();
                thisCommand.CommandText = "select std_name,std_id from std_info";
                SqlDataReader thisReader = thisCommand.ExecuteReader();
                while (thisReader.Read())
                {
                    if (textBox1.Text == System.Convert.ToString(thisReader["std_name"]) &&
                            textBox2.Text == System.Convert.ToString(thisReader["std_id"]))
                    {
                        MessageBox.Show("登录成功!", "确定", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        button3.Visible = true;
                        button4.Visible = true;
                        button5.Visible = true;
                        button17.Visible = true;
                        tabControl1.Visible = true;
                        break;
                    }
                }
                while (!thisReader.Read())
                {
                    MessageBox.Show("账号或密码错误!", "警告!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
                thisReader.Close();
                thisConnection.Close();
            }
    这样比较复杂,但也算一种方法吧
      

  3.   


     入门的,上www.51aspx.com上找,多得很,都是源码
      

  4.   

    这是ADO.NET最基础知识
    你可以参考