Quantcast
Channel: imagen condicional.
Viewing all articles
Browse latest Browse all 3

imagen condicional.

0
0

Necesito hacer que guardar una imagen sea opcional, si el usuario quiere puede añadir la imagen sino se guardan los demás datos sin la imagen.

Este es el código de guardar:

      FileStream fstream = new FileStream(this.ruta.Text, FileMode.Open, FileAccess.Read);
            byte[] imagebit = new byte [fstream.Length];
           fstream.Read(imagebit, 0, Convert.ToInt32(fstream.Length));
            OleDbCommand cmd = new OleDbCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "Insert into Costos values('" + txtno.Text + "','" + config.Text + "','" + txtmaql.Text + "', '" + txtco2l.Text + "','"+ txtenergial.Text + "', '" + txtotrol.Text + "','" + txtdepre.Text + "', '" + txttubo.Text + "', '" + txtsalario.Text + "','" + txttotalcosto.Text + "', @Imagen)";
            cmd.Connection = connection;
            OleDbParameter img = new OleDbParameter("@Imagen", OleDbType.VarBinary, imagebit.Length, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, imagebit);
            cmd.Parameters.Add(img);
            cmd.ExecuteNonQuery();
            MessageBox.Show("Datos guardados.");


Viewing all articles
Browse latest Browse all 3

Latest Images





Latest Images