나는이 코드를 가졌다.처리되지 않은 SQLException은 어디서 비롯된 것입니까?
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection cnn;
string connectionString;
connectionString = "server=.\\sqlexpress;database=Blue;trusted_connection=true";
cnn = new SqlConnection(connectionString);
MemoryStream stream = new MemoryStream();
cnn.Open();
SqlCommand command = new SqlCommand("select Image from ImageParts where ImageName=" + listBox1.SelectedIndex, cnn);
byte[] image = (byte[])command.ExecuteScalar();
stream.Write(image, 0, image.Length);
cnn.Close();
Bitmap bitmap = new Bitmap(stream);
pictureBox1.Image = bitmap;
}
내가 그런 다음 listBox1.Items
에서 ImageName
을 저장 한 오류가 온다.
varchar 값 'c1.jpg'을 데이터 유형 int로 변환 할 때 변환하지 못했습니다.
무엇이 문제 일 수 있습니까? C#을 처음 접했을 때 이러한 오류에 익숙하지 않았습니다.
나는 Shark에 동의한다. 여기서 문제는 데이터 유형 불일치이다. –