求C#写一个登陆源代码

来源:百度知道 编辑:UC知道 时间:2024/05/15 23:57:47
access数据库名:myta

表名:myta

(字段:username,password)

要求:登陆成功转到From2,失败就显示失败。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace 学生信息管理系统
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}

public bool blCanLogin;
OleDbConnection connection1 = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = C:\\db1.mdb");
private void button1_Click(object sender, EventArgs e)
{
blCanLogin = false;

string sql = "select name,passwd from userinfo";
DataRow myRow;
connection1.Open();
OleDbDataAdapter adp = new OleDbDataAdapter(sql, connection1);
DataSet ds = new DataSe