从数据类型为nvarchar到VARBINARY(最大)隐式转换不允许
问题描述:
我从下面的代码得到以下错误:从数据类型为nvarchar到VARBINARY(最大)从数据类型为nvarchar到VARBINARY(最大)隐式转换不允许
隐式转换是不允许的。使用CONVERT函数来运行此查询。
protected void btnOKImageUpload_Click(object sender, EventArgs e)
{
try
{
string filePath = "";
string fileName = "";
int UserId = Convert.ToInt32(hdnUserId.Value);
if (fileImage.HasFile)
{
if (CheckFileType(fileImage.FileName))
{
filePath = Server.MapPath(Application["UploadFolder"].ToString());
if (UserId > -1)
{
fileName = "Image_" + UserId.ToString() + Path.GetExtension(fileImage.FileName);
}
else
{
fileName = Path.GetFileName(fileImage.FileName);
}
string virFileName = Application["UploadFolder"].ToString() + "/" + fileName;
string tmpFileName = Path.Combine(filePath, fileName);
fileImage.SaveAs(tmpFileName);
SessionData.LocationFloorPlanFile = tmpFileName;
DataAccess.SaveEmployeeImage(UserId, fileName);
hdnImageFileName.Value = fileName;
txtImageUpload.Text = virFileName;
//btnFloorPlanView.HRef = hdnFloorPlan.Value;
btnImageUpload.Disabled = true;
btnImageDelete.Enabled = true;
hdnPostbackAction.Value = "UPLOAD";
}
}
}
catch (Exception ex)
{
hdnErrMsg.Value = ex.Message;
//"An error has occurred while processing your request. Please contact support for further assistance.";
}
}
public static void SaveEmployeeImage(int userId, string imageFilePath)
{
ArrayList paramaters = getParamArray();
paramaters.Add(getParam("@userId", DbType.Int32, userId));
paramaters.Add(getParam("@imageFilePath", DbType.AnsiString, imageFilePath));
executeNonQuery("xp_SaveEmployeeImage", paramaters);
}
我的过程需要帐户及图像,插入到表中。
需要更改哪些数据类型?
你的sproc是什么样的? –
你似乎正在向数据库发送一个字符串值,你确定它不应该是一个字节数组? – Tejs
我看到你在使用'ArrayList',只觉得脏。 –