السلام عليكم
تغيير كود تحقق من اسم مستخدم والرقم السرى الى دلفى
SqlConnection con;
SqlCommand cmd;
SqlDataReader reader;
DialogResult dr;
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
public void get_connection()
{
try
{
con = new SqlConnection();
con.ConnectionString = "database=Ink_manager";
//“Data Source=(local);Initial Catalog=ashraftest;user id=sa;password=faisal”;
}
catch
{
dr = MessageBox.Show(" There is no Connection", "Connection Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
}
}
public void login_to_DB()
{
try
{
get_connection();
cmd = new SqlCommand();
con.Open();
cmd.Connection = con;
cmd.CommandText = "select password from users where user_name=@U";
cmd.Parameters.Add("@U", textBox1.Text);
reader = cmd.ExecuteReader();
if (reader.HasRows == false)
{
MessageBox.Show("Please Enter your Username and Password to Login");
}
if (reader.Read())
{
if (textBox2.Text == reader***91;"password"***93;.ToString())
{
//MessageBox .Show ("yes");
main mainfrm = new main();
this.Hide();
mainfrm.ShowDialog();
}
else
{
MessageBox.Show("Invalid Username or Password");
}
}
con.Close();
}
catch
{
MessageBox.Show("Error");
}
}
private void button1_Click_1(object sender, System.EventArgs e)
{
login_to_DB();
}
private void button2_Click_1(object sender, System.EventArgs e)
{
Application .Exit();
}Dim CONN As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\MyDataProject.mdb")
Dim DS As New DataSet
Dim DB As New OleDbDataAdapter
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error Resume Next
DS.Clear()
Dim Str As String = "SELECT * FROM USERS WHERE UserName='" & TextBox1.Text & "' and UserPass='" & TextBox2.Text & "'"
DB = New OleDbDataAdapter(Str, CONN)
DB.Fill(DS, "USERS")
If DS.Tables("USERS").Rows.Count > 0 Then
DB.Dispose()
CONN.Dispose()
MessageBox.Show("مبرووووووك لقد تم تسجيل دخولك للبرنامج", " برنامج التحقق من اسم المستخدم ", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading)
CONN.Dispose()
Else
MessageBox.Show("تأكد من إدخال كلمة السر أو اسم المستخدم بشكل صحيح", "برنامج التحقق من اسم المستخدم ", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading)
Me.TextBox1.Focus()
End Ifارغب فى تحويله الى اكود دلفى لحيث عن اسم مستخدم فى قاعدة بيانات mysql