Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button1_Click(object sender, EventArgs e)
- {
- OpenFileDialog getImage = new OpenFileDialog();
- getImage.InitialDirectory = "C:\";
- getImage.Filter = "Archivos de Imagen (*.jpg)(*.jpeg)|*.jpg;*.jpeg|PNG(*.png)|*.png";
- if (getImage.ShowDialog() == DialogResult.OK)
- {
- pictureBox1.ImageLocation = getImage.FileName;
- pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
- }
- else
- {
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (textBox1.Text != "" || comboBox1.Text != "" || comboBox2.Text != "")
- {
- SqlCommand agregar = new SqlCommand("Insert Into Equipos values ((RTRIM(LTRIM(" + textBox1.Text + "))), (RTRIM(LTRIM('" + variable + "'))), (RTRIM(LTRIM('" + textBox3.Text + "'))) ,(RTRIM(LTRIM('" + textBox2.Text + "'))), (RTRIM(LTRIM('" + comboBox1.Text + "'))), (RTRIM(LTRIM('" + comboBox2.Text + "'))), (RTRIM(LTRIM('" + textBox10.Text + "'))), @Imagen)", cadena);
- try
- {
- cadena.Open();
- agregar.ExecuteNonQuery();
- MessageBox.Show("Agregado");
- Variables.equipos1 = textBox1.Text;
- Variables.equipos2 = variable;
- Variables.equipos3 = textBox2.Text;
- Variables.equipos4 = comboBox1.Text;
- Variables.equipos5 = comboBox2.Text;
- Variables.equipos6 = textBox10.Text;
- Variables.dialogo = true;
- }
- catch (Exception ex)
- {
- MessageBox.Show("Error" + ex);
- }
- finally
- {
- cadena.Close();
- textBox1.Clear();
- textBox2.Clear();
- }
- }
- else
- {
- cadena.Close();
- MessageBox.Show("No puede dejar vacio");
- textBox2.Clear();
- }
- }
- public byte[] ImageToByteArray(System.Drawing.Image imagen)
- {
- MemoryStream ms = new MemoryStream();
- imagen.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
- return ms.ToArray();
- }
- byte[] byteArrayImagen = ImageToByteArray(PictureBox1.Image)
- SqlCommand command = new SqlCommand();
- command.Text="INSERT INTO TABLA (CAMPO) values (@imagen)";
- command.Parameters.AddWithValue("@imagen",byteArrayImagen);
- command.ExecuteNonQuery();
Add Comment
Please, Sign In to add comment