欢迎来到天天文库
浏览记录
ID:56277547
大小:467.50 KB
页数:60页
时间:2020-06-05
《C#实验c_图书管理系统源代码.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1.登陆界面OleDbConnectioncn=newOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\test.mdb;");cn.Open();cn.Close();//读取数据到DataTableOleDbConnectioncn=newOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\test.mdb;");DataTableuserTbl=newD
2、ataTable();OleDbDataAdapterda=newOleDbDataAdapter("SELECT*FROM[User]",cn);da.Fill(userTbl);//插入一条记录OleDbConnectioncn=newOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\test.mdb;");OleDbCommandcmd=newOleDbCommand("INSERTINTO[User]([ID],[UserNam
3、e],[UserPassword])VALUES(1,'user_ab','123')",cn);cn.Open();cmd.ExecuteNonQuery();cn.Close();//更新OleDbConnectioncn=newOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\test.mdb;");OleDbCommandcmd=newOleDbCommand("UPDATE[User]SET[UserPassword]='ne
4、wpwd'WHERE[UserName]='user_ab'",cn);cn.Open();cmd.ExecuteNonQuery();cn.Close();主要代码:publicpartialclassLoginForm:Form{publicstaticstringuacc;publicstaticstringupsw;publicstaticstringuname;publicstaticstringusex;publicstaticstringupart;publicstaticstringuright;p
5、ublicLoginForm(){InitializeComponent();}privatevoidloginbtn_Click(objectsender,EventArgse){if(this.useracctxt.Text.Trim()==""&&this.pswtxt.Text==""){MessageBox.Show("请输入您的用户名和密码!","提示!");return;}try{stringsql;sql="select*fromtb_userwhereuacc='"+this.useracctxt
6、.Text+"'andupsw='"+this.pswtxt.Text+"'";OleDbDataReaderdr=DBHelp.OleReader(sql);dr.Read();if(dr.HasRows){uacc=this.useracctxt.Text;upsw=this.pswtxt.Text;uname=dr["uname"].ToString();usex=dr["usex"].ToString();upart=dr["upart"].ToString();uright=dr["uright"].To
7、String();MainFormaf=newMainForm(this);this.Hide();this.useracctxt.Clear();this.pswtxt.Clear();af.Show();}else{MessageBox.Show("账号或密码错误!","提示!");this.useracctxt.Clear();this.pswtxt.Clear();this.useracctxt.Focus();}}catch(Exception){MessageBox.Show("数据库无法连接!","警
8、告!");}}privatevoidcancelbtn_Click(objectsender,EventArgse){Application.Exit();}privatevoidLoginForm_Closing(objectsender,FormClosingEventArgse){Application.Exit();}}2.主界面(图较小,自己可以拉
此文档下载收益归作者所有