标题:C#跳转问题
只看楼主
zhang1985
Rank: 1
等 级:新手上路
帖 子:67
专家分:0
注 册:2006-10-24
结帖率:100%
 问题点数:0 回复次数:2 
C#跳转问题
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data.Odbc;

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

        private void button1_Click(object sender, EventArgs e)
        {
            
            if (textBox1.Text.Trim() == "")
            {
                MessageBox.Show("姓名不能为空");
                return;
            }
            SqlConnection cmd = new SqlConnection("server=(local);User ID=sa;pwd=;Database=zhonhouse");
            cmd.Open();
            SqlCommand cnd = new SqlCommand("select count(*) from login where login_id=" + textBox1.Text + " and login_pwd=" + textBox2.Text + "",cmd);
            // = "select count(*) from login where login_name=" + textBox1.Text + " and login_pwd=" + textBox2.Text + "";
            Int32 count = (Int32)cnd.ExecuteScalar();
            if (count > 0)
            {
                MessageBox.Show("ok");
            }
            else
            {
                MessageBox.Show("no");
            }
            
        }
        
    }
}
这是在FROM1中窗口的代码
当我连接数据库后 如果OK 需跳转到FROM2的窗口中
 那代码怎么实现呢
搜索更多相关主题的帖子: public private 
2010-02-26 10:49
saitor
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:5
帖 子:373
专家分:1520
注 册:2009-5-18
得分:0 
new 个 form2
2010-02-26 11:48
happy886
Rank: 3Rank: 3
来 自:河南
等 级:论坛游侠
威 望:3
帖 子:130
专家分:120
注 册:2009-3-21
得分:0 
form2 newForm=new form2();
newForm.Show();       //打开Form2界面
this.Hide();          //隐藏本界面

OK

happy  C#
2010-02-26 17:19



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




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

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