0% found this document useful (0 votes)
37 views1 page

Messagebox: "Campo Vacio." "Select From Clave Where Clave '" "'" "Clave" "Clave" "Clave" "Clave Correcta"

This code is checking a password entered in a text box against a database. It opens a connection to the database, selects the row where the password matches the text box value, and checks if they are equal. If they match, it enables controls on a form and sets a message. If they do not match, it displays an error message. It handles any exceptions by displaying an error message.

Uploaded by

alejo_20
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views1 page

Messagebox: "Campo Vacio." "Select From Clave Where Clave '" "'" "Clave" "Clave" "Clave" "Clave Correcta"

This code is checking a password entered in a text box against a database. It opens a connection to the database, selects the row where the password matches the text box value, and checks if they are equal. If they match, it enables controls on a form and sets a message. If they do not match, it displays an error message. It handles any exceptions by displaying an error message.

Uploaded by

alejo_20
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

try { if (clave.Text == string.Empty) { MessageBox.Show("Campo Vacio."); } cn.Open(); OleDbCommand cmd = new OleDbCommand("select * from clave where clave='" + clave.

Text + "'", cn); OleDbDataAdapter da = new OleDbDataAdapter(cmd); da.Fill(ds, "clave"); DataRow dr; dr = ds.Tables["clave"].Rows[0]; if (clave.Text == dr["clave"].ToString()) { MessageBox.Show("Clave Correcta"); foreach (Control c in this.groupBox1.Controls) { if (c is TextBox) { c.Text = ""; } c.Enabled = true; groupBox1.Text = "Acceso"; groupBox1.Enabled = true; clave.Enabled=false; reg.Enabled = true; } } else if (clave.Text != dr["clave"].ToString()) { MessageBox.Show("Clave Erronea!!"); } cn.Close(); } catch (Exception ex) { MessageBox.Show("Clave Erronea."); }

You might also like