Good morning, I am working with an application within C #, which works as an inventory for the teams within the company. I'm working inside Windows Forms.
What I intend to do is keep the records of each computer, with its respective image for easier location.
It is worth mentioning that the field of the database declares it as image:
This is how I am loading the image inside the PictureBox:
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
{
}
}
This is how I intend to put them in the database:
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();
}
}
The error that shows me when executing it like this is the following: