DDS_312
2022-05-21 16:49
采纳率: 33.3%
浏览 32

System.InvalidCastException: 从“System.String”到“System.Byte[]”的强制转换无效。

[InvalidCastException: 从“System.String”到“System.Byte[]”的强制转换无效。]

asp.net+SQL server通过界面向库里上传图片时出现System.InvalidCastException: 从“System.String”到“System.Byte[]”的强制转换无效。

System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) +12654916
System.String.System.IConvertible.ToType(Type type, IFormatProvider provider) +14
System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +12655621
System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType, Boolean& coercedToDataFeed, Boolean& typeChanged, Boolean allowStreaming) +1341

[InvalidCastException: 将参数值从 String 转换到 Byte[] 失败。]
System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType, Boolean& coercedToDataFeed, Boolean& typeChanged, Boolean allowStreaming) +1388
System.Data.SqlClient.SqlParameter.GetCoercedValue() +187
System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc) +172
System.Data.SqlClient.SqlCommand.BuildParamList(TdsParser parser, SqlParameterCollection parameters, Boolean includeReturnValue) +207
System.Data.SqlClient.SqlCommand.BuildExecuteSql(CommandBehavior behavior, String commandText, SqlParameterCollection parameters, _SqlRPC& rpc) +249
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +2698
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +1611 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +390
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +207
SGH.T3_1.Button2_Click(Object sender, EventArgs e) in E:\桌面\毕业设计代码\ASP\SGH\T3-1.aspx.cs:62
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9796650
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +211

asp.net+SQL server通过界面向库里上传图片时出现System.InvalidCastException: 从“System.String”到“System.Byte[]”的强制转换无效。
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1696System.InvalidCastException: 从“System.String”到“System.Byte[]”的强制转换无效。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题