标题:关于登录界面的几个问题
取消只看楼主
zljun0806
Rank: 1
等 级:新手上路
帖 子:3
专家分:4
注 册:2010-11-1
结帖率:100%
已结贴  问题点数:20 回复次数:1 
关于登录界面的几个问题
小弟是刚学习C#的初学者,在做一个登陆界面的时候出现了几个问题,希望高手们帮忙解决下,小弟现在这里谢过了
出现的问题:
程序代码:
using System;
using System.Collections.Generic;
using using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Odbc;
using System.Data.SqlClient;

namespace Login
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {
        }
         private void label2_Click(object sender, EventArgs e)
        {
        }
   
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show(" 用户名或密码不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                 string strConnection = "user id = sa;password =admin;";

                 strConnection += "Database = Project ;Server = ZLJUN\\GSQL;";

                   
               SqlConnection objConnection = new SqlConnection(strConnection);

                string sqlStr = "select * from login where login_name = '" + textBox1.Text
                    + "' and  login_password = '" + textBox2.Text + "'";
                SqlConnection objConnection = new SqlConnectio(sqlStr, objConnection);


                DataTable dt = new DataTable();   
                objConnection.Fill(dt);
                int i = dt.Rows.Count;           
                if (i >= 1)
                {
                    MessageBox.Show("用户名和密码都正确,可以成功登录!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
               
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
出现的问题:


搜索更多相关主题的帖子: 界面 登录 
2010-11-01 17:37
zljun0806
Rank: 1
等 级:新手上路
帖 子:3
专家分:4
注 册:2010-11-1
得分:0 
回复 2楼 筱晓绾
小弟拜谢!!!
2010-11-01 20:40



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-324650-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.113884 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved