C# 코드 : // 여기서 테이블에 값을 삽입하려고합니다.명령 실행 중 치명적인 오류가 발생했습니다.
case true:
Connection.Connect();
int fk_pic = IdPic();
string insertWork = "INSERT INTO work (fk_id_pic, fk_login, university, lesson, name, info, date_work, price) VALUES (@fk_pic, @fk_login, @university, @lesson, @name, @info, @date_work, @price); Allow User Variables = true;";
MySqlCommand work = new MySqlCommand(insertWork, Connection.Connect());
work.Parameters.AddWithValue("@fk_pic", fk_pic);
work.Parameters.AddWithValue("@fk_login", Program.form1.login);
work.Parameters.AddWithValue("@university", textBox1.Text);
work.Parameters.AddWithValue("@lesson", textBox2.Text);
work.Parameters.AddWithValue("@name", textBox3.Text);
work.Parameters.AddWithValue("@info", richTextBox1.Text);
work.Parameters.AddWithValue("@date_work", DateTime.Now);
work.Parameters.AddWithValue("@ price", textBox4.Text);
work.ExecuteNonQuery();
Connection.Disconnect();
break;
SQL 쿼리 :
CREATE TABLE pic
(
id_pic INTEGER UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'id of image',
caption CHAR(45) NOT NULL COMMENT 'the name of image',
who_add CHAR(30) NOT NULL COMMENT 'who add this image',
img LONGBLOB NOT NULL,
CONSTRAINT pkId_pic PRIMARY KEY(id_pic)
)
COMMENT 'Table for hosting images';
무엇을 해야할지하지 마십시오. 응답 대기 중)
무엇이 오류입니까? –
예외 메시지와 같은 오류 세부 정보를 게시 할 수 있습니까? –
"work.Parameters.AddWithValue ("@ price ", textBox4.Text);" - "@"다음에 공백이 없어야합니다. –