این کد با سی شارپه مال یکی از برنامه های قدیمیم ببین به دردت میخوره
private void btnenter_Click_1(object sender, EventArgs e)
{
for (int i = 0; i < txtpass.Text.Length; i++)
{
if (txtpass.Text[i]=='\'')
{
MessageBox.Show("توجه در پسورد و شناسه از علائم(',\",.,\\,;,?,@,...) نباید استفاده شود!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtid.Clear();
txtpass.Clear();
txtid.Select();
return;
}
}
for (int i = 0; i < txtid.Text.Length; i++)
{
if (txtid.Text[i] == '\'')
{
MessageBox.Show("توجه در پسورد و شناسه از علائم(',\",.,\\,;,?,@,...) نباید استفاده شود!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtid.Clear();
txtpass.Clear();
txtid.Select();
return;
}
}
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|HelalDb.mdb;Jet OLEDB:Database Password=12344321;");
//string oledbConnectString ="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|hdb.accdb;Jet OLEDB:Database Password=12344321;";
con.Open();
string s="select * From users where id='" + txtid.Text + "' and pass='" + txtpass.Text + "'";
OleDbDataAdapter da = new OleDbDataAdapter(s, con);
DataSet ds = new DataSet();
da.Fill(ds, "users");
if (ds.Tables[0].Rows.Count == 0)
{
MessageBox.Show("اطلاعات ورودی اشتباه است لطفا دوباره سعی کنید", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtpass.Clear();
txtid.Clear();
txtid.Select();
return;
}
else
{
Program.gp.right = ds.Tables[0].Rows[0][2].ToString();
Program.gp.struser = ds.Tables[0].Rows[0][0].ToString();
m2 = 1;//becuse if this window closed we can understand clicked on close and exit from form or type a true pass and close form to general part
Close();
}
}