这是我的代码,这个我没有用三层架构,我直接在UI层的按钮事件就写完了,请问要怎么改成三层架构呢,BLL要干什么,DAL要干什么?
这是登陆后,显示个人信息的。
2、另外当我datareader,用getstring之后,如果遇到int型的就读不出来然后就结束了,这怎么办,我只能把数据库里int型的改成vchar凑合过去了。。。
public SqlConnection GetConn()
{
return new SqlConnection("Data Source=localhost;Initial Catalog=Library;Integrated Security=True");
}//获取链接字符串
private void information_Load(object sender, EventArgs e)
{
textBox1.Text = Userhelper.id;
using (SqlConnection c = GetConn())
{
textBox1.Text = Userhelper.id;
string sqlString = "select Rname,Rage,Rsex,Rdep from Reader where Rno=" + Userhelper.id;
SqlCommand cmd = new SqlCommand(sqlString, c);
c.Open();
SqlDataReader r = cmd.ExecuteReader();
while (r.Read())
{
textBox2.Text = r.GetString(0);
textBox3.Text = r.GetString(1);
textBox4.Text = r.GetString(2);
textBox5.Text = r.GetString(3);
}
}
}