首页 / C# / 使用C#开发数据库应用系统
使用C#开发数据库应用系统
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了使用C#开发数据库应用系统,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2397字,纯文字阅读大概需要4分钟。
内容图文
System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace 第一章 { public partial class frmMain : Form { //连接字符串 private const string sqlcon = "Data Source=.;Initial Catalog=MySchool;User ID=sa;Pwd=."; //用于打开/关闭数据库连接 SqlConnection con = new SqlConnection(sqlcon); //构造方法:用来做初始化工作 public frmMain() { InitializeComponent(); } //取消按钮的单击事件 private void btnexit_Click(object sender, EventArgs e) { DialogResult result= MessageBox.Show("是否取消?","提示",MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { //关闭窗体 this.Close(); } else { //清空窗体中所有信息 this.txtName.Clear(); this.txtPwd.Clear(); this.cborow.SelectedIndex = -1 ; } } //登录按钮的单击事件 private void btnOK_Click(object sender, EventArgs e) { if (CheckInput()) { try { con.Open(); string sql = "select count(*) from Student where StudentNo=‘" + this.txtName.Text + "‘ and LoginPwd=‘" + this.txtPwd.Text + "‘"; SqlCommand com = new SqlCommand(sql, con); int count = (int)com.ExecuteScalar(); if (count > 0) { MessageBox.Show("登陆成功!", "提示"); //创建出FrmTest窗体 FrmTest test = new FrmTest(); //test代表的就是FrmTest窗体 .Test就是标题 test.txtshow.Text = "欢迎您:" + this.txtName.Text; test.Show(); } else { MessageBox.Show("登陆失败!", "提示"); this.txtName.Clear(); this.txtPwd.Clear(); this.cborow.SelectedIndex = -1; } } catch (Exception ex) { Console.WriteLine(ex); } finally { con.Close(); } } } //在点击登录按钮的时候验证文本框内容是否为空 private bool CheckInput() { bool flag = true; //判断文本框是否输入值了? //判断txtName是否输入值了 if (this.txtName.Text.Trim()== null||this.txtName.Text.Trim() =="") { //提示信息 MessageBox.Show("请输入登录账号!","登录验证"); flag = false; }else if (this.txtPwd.Text.Trim() == null || this.txtPwd.Text.Trim() == "") { //提示信息 MessageBox.Show("请输入登录密码!", "登录验证"); flag = false; } else if (this.cborow.Text.Trim() == null || this.cborow.Text.Trim() == "") { MessageBox.Show("请选择登录角色!", "登录验证"); flag = false; } return flag; } } }
使用C#开发数据库应用系统
标签:.sh 显示 tar 传递 scalar order linq 多行 winform
本文系统来源:http://www.cnblogs.com/3020815dzq/p/7777546.html
内容总结
以上是互联网集市为您收集整理的使用C#开发数据库应用系统全部内容,希望文章能够帮你解决使用C#开发数据库应用系统所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。