17,748
社区成员
发帖
与我相关
我的任务
分享using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace ADL
{
public class lognAdl
{
public void logn_sql(string userName, string password)
{
string str = "server=.;database=" + userName + ";uid=sa;" + password;
SqlConnection conn = new SqlConnection(str);
conn.Open();
}
}
}
DAL类库中的数据using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace BLL
{
public class Logn
{
public void bllogn(string userName,string passwoed)
{
if (userName == "" || passwoed == "")
{
throw new Exception("请输入正确!");
}
ADL.lognAdl lad = new ADL.lognAdl();
lad.logn_sql(userName, passwoed);
}
}
}
BLL类库中的数据using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 学生管理系统
{
public partial class Log_on : Form
{
public Log_on()
{
InitializeComponent();
}
private void Logn_Click(object sender, EventArgs e)
{
BLL.Logn ln = new BLL.Logn();
try
{
ln.bllogn(textBox1.Text, textBox2.Text);
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
}
}
主窗体的代码