我從下面的代碼得到以下錯誤:從數據類型爲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',只覺得髒。 –