日期:2014-05-17 浏览次数:21031 次
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");
}