string comando = "SELECT * FROM Personal WHERE Legajo LIKE'" + txtLegajo.text + '");
private void button1_Click(object sender, EventArgs e) { string comando = "SELECT * FROM Personal WHERE Legajo LIKE'" + txtLegajo.Text + "')"; if (comando) { Form2 segundo = new Form2(); segundo.ShowDialog(); }
"SELECT Legajo FROM Personal WHERE Legajo ='" + txtLegajo.Text + "'";si(<Resultado de la SQL> es igual a txtLejago.Text) { Form2 segundo = new Form2(); segundo.ShowDialog(); }
SqlCeConnection conn = new SqlCeConnection(); StringBuilder sbQuery = new StringBuilder(); SqlCeCommand cmd = new SqlCeCommand(); IDataReader dr; sbQuery.Append("SELECT Legajo FROM Personal WHERE Legajo = " + txtLegajo.Text + "'"); cmd.CommandText = sbQuery.ToString(); cmd.Connection = conn; dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr["Legajo"].ToString() == txtLegajo.Text) { Form2 segundo = new Form2(); segundo.ShowDialog(); } } dr.Close();
private void button1_Click(object sender, EventArgs e) { OleDbConnection conn = new OleDbConnection(); conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =\"C:\\Users\\AsusB85M-G\\Desktop\\Personal.accdb\""; StringBuilder sbQuery = new StringBuilder(); OleDbCommand cmd = new OleDbCommand(); OleDbDataReader lector; string consultaSQL = "SELECT Legajo FROM Personal WHERE Legajo = " + txtLegajo.Text + "'"; cmd.CommandText = sbQuery.ToString(); cmd.Connection = conn; try { conn.Open(); } catch (Exception excepcion) { Console.Write(excepcion.Message); Console.ReadLine(); } if (conn.State == ConnectionState.Open) { try { lector = cmd.ExecuteReader(); while (lector.Read()) { if (lector["Legajo"].ToString() == txtLegajo.Text) { Form2 segundo = new Form2(); segundo.ShowDialog(); } } } catch (Exception excepcion) { Console.Write(excepcion.Message); Console.ReadLine(); } conn.Close(); } } }}
if (lector["Legajo"].ToString() == txtLegajo.Text) { Form2 segundo = new Form2(); segundo.ShowDialog(); } else ...
string consultaSQL = "SELECT Legajo FROM Personal WHERE Legajo = " + txtLegajo.Text + "";
private void button1_Click(object sender, EventArgs e) { OleDbConnection conn = new OleDbConnection(); conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =\"C:\\Users\\AsusB85M-G\\Desktop\\Personal.accdb\""; OleDbCommand cmd; string consultaSQL = "INSERT INTO InasistenciasJefatura (Legajo,Estado,Fecha,Cargo,Turno,Aviso) VALUES " + txtLeg.Text + ""+ txtEstado.Items + "" + txtFecha.Text +""+ Cargo.Items + ""+ txtTurno.Text + "" + txtAviso.Text+ "" ; cmd = new OleDbCommand(consultaSQL, conn); cmd.Connection = conn; try { conn.Open(); } catch (Exception excepcion) { Console.Write(excepcion.Message); Console.ReadLine(); } if (conn.State == ConnectionState.Open) { try { cmd.ExecuteNonQuery(); } catch (Exception excepcion) { Console.Write(excepcion.Message); Console.ReadLine(); } conn.Close(); } } }}
sbQuery = new StringBuilder(""); sbQuery.Append("INSERT INTO Inventario VALUES(@PAlmacen, @PFecha, @PArticulo, @PUnidades)"); cmd.CommandText = sbQuery.ToString(); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@PAlmacen", tbAlmacen.Text); cmd.Parameters.AddWithValue("@PFecha", dtFecha.Value.Date); cmd.Parameters.AddWithValue("@PArticulo", tbArticulo.Text); cmd.Parameters.AddWithValue("@PUnidades", dUnidades); cmd.Connection = conn; cmd.ExecuteNonQuery();
private void button1_Click(object sender, EventArgs e) { OleDbConnection conn = new OleDbConnection(); conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =\"C:\\Users\\AsusB85M-G\\Desktop\\Personal.accdb\""; OleDbCommand cmd; //string consultaSQL = "INSERT INTO InasistenciasJefatura (Legajo,Estado,Fecha,Cargo,Turno,Aviso) VALUES " + txtLeg.Text + ""+ txtEstado.Items + "" + txtFecha.Text +""+ Cargo.Items + ""+ txtTurno.Text + "" + txtAviso.Text+ "" ; string consultaSQL = "INSERT INTO Inventario (Legajo, Estado, Fecha, Cargo, Turno, Aviso) VALUES(@Legajo, @Estado, @Fecha, @Cargo, @Turno, @Aviso)"; cmd = new OleDbCommand(consultaSQL, conn); cmd.Connection = conn; cmd.Parameters.AddWithValue("@Legajo", txtLeg.Text); cmd.Parameters.AddWithValue("@Estado", txtEstado.Items); cmd.Parameters.AddWithValue("@Fecha", txtFecha.Text); cmd.Parameters.AddWithValue("@Cargo", Cargo.Items); cmd.Parameters.AddWithValue("@Aviso", txtAviso.Text); try { conn.Open(); } catch (Exception excepcion) { Console.Write(excepcion.Message); Console.ReadLine(); } if (conn.State == ConnectionState.Open) { try { cmd.ExecuteNonQuery(); } catch (Exception excepcion) { Console.Write(excepcion.Message); Console.ReadLine(); } conn.Close(); }
private void button1_Click(object sender, EventArgs e) { OleDbConnection conn = new OleDbConnection(); conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =\"C:\\Users\\AsusB85M-G\\Desktop\\Personal.accdb\""; OleDbCommand cmd; //string consultaSQL = "INSERT INTO InasistenciasJefatura (Legajo,Estado,Fecha,Cargo,Turno,Aviso) VALUES " + txtLeg.Text + ""+ txtEstado.Items + "" + txtFecha.Text +""+ Cargo.Items + ""+ txtTurno.Text + "" + txtAviso.Text+ "" ; string consultaSQL = "INSERT INTO InasistenciaJefatura (Legajo, Estado, Fecha, Cargo, Turno, Aviso) VALUES (@Legajo, @Estado, @Fecha, @Cargo, @Turno, @Aviso)"; cmd = new OleDbCommand(consultaSQL, conn); cmd.Connection = conn; try { conn.Open(); } catch (Exception excepcion) { Console.Write(excepcion.Message); Console.ReadLine(); } if (conn.State == ConnectionState.Open) { try { cmd.Parameters.AddWithValue("@Legajo", txtLeg.Text); cmd.Parameters.AddWithValue("@Estado", txtEstado.Items); cmd.Parameters.AddWithValue("@Fecha", txtFecha.Text); cmd.Parameters.AddWithValue("@Cargo", Cargo.Items); cmd.Parameters.AddWithValue("@Aviso", txtAviso.Text); cmd.ExecuteNonQuery(); } catch (Exception excepcion) { Console.Write(excepcion.Message); Console.ReadLine(); } conn.Close(); }