C#编程 家庭理财系统 代码追踪学习

chenjinglong chenjinglong 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
登录实现 与SQL server链接
定义数据库连接类
class DBHelper
{
private static string strSql = string.Format(@"server=CHENJINGLONGPC\SQLEXPRESS;database=FamilyFinace;Integrated Security=True");
public static SqlConnection connect= new SqlConnection(strSql);
}
登录系统
try
{
DBHelper.connect.Open();
string sql = string.Format(@"select count(*) from FamilyUser where UserName='{0}' and UserPassword='{1}'", txtUserName.Text.Trim(), txtPassWord.Text);
SqlCommand conform = new SqlCommand(sql, DBHelper.connect);
int result = (int)conform.ExecuteScalar();
if (result > 0)
{
this.DialogResult = DialogResult.OK;
}
else
{
lblUPError.Visible = true;
}

// MessageBox.Show("success");
}

catch (SqlException ex)
{
MessageBox.Show("登录失败 原因如下" + ex.Message, "家庭理财管理系统");
}
finally
{
DBHelper.connect.Close();
}
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
chenjinglong
C# 111,128 成员 642,536 内容