帮忙找错~!
string strTitle,strSql,strReturn;
int intHonorID= Convert.ToInt32(this.ddlhonor.SelectedValue);
strTitle = this.txtName.Text.Trim();
strSql = "insert into Honor(title,honorid,image) values ( ' "+strTitle+ " ', ' "+intHonorID+ " ', ' "+strPhotoPath+ " ') ";
strReturn = this.objDB.ReturnSQL(strSql);
if(strReturn != "1 ")
{
JScript.Alert(strReturn);
return;
}
else
{
this.txtName.Text = " ";
this.ddlhonor.SelectedValue = "0 ";
this.BindData();
}
这里的strPhotoPath为图片上传转换后的相对路径地址.
测试一组数据,可以取得:insert into Honor(title,honorid,image) values ( 'sss ', '0 ', '..\UpFile\2007176232716狗狗.jpg ')
错误提示insert into语句语法错误!
我的SQL语句错在那了呢?
------解决方案--------------------都不知道字段类型是什么,谁知道错哪里了
------解决方案--------------------是那一种数据库, 如果是SQLServer , image是 keyword
insert into Honor(title,honorid,image
应该是
insert into Honor(title,honorid,[image]).........
------解决方案--------------------strSql = "insert into Honor(title,honorid,image) values ( ' "+strTitle+ " ', ' "+intHonorID+ " ', ' "+strPhotoPath+ " ') ";
-------------------------------------------------------
改成
strSql = "insert into Honor(title,honorid,image) values ( ' "+strTitle+ " ', "+intHonorID+ ", ' "+strPhotoPath+ " ') ";
数字不要‘’
------解决方案--------------------关键字问题 一样适用于access