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的窗口中
那代码怎么实现呢