I have pretty much exhausted all of my knowledge up to this point, I keep getting an error on VS 2019: (System.NotSupportedException HResult=0x80131515 Message=The member ScreenShot of type System.Drawing.Bitmap cannot be used as a parameter value Source=Dapper) I am attempting to save a screenshot to a SQL database, I have created a stored procedure to save it to the table. I understand that I need to convert it from bitmap to binary and its being stored in SQL as varbinary(MAX). I just do not know where I need to place that conversion. Perhaps, that is not even the issue here. I greatly appreciate any advice, and thank you all ahead of time.
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig2.CnnString("REPORTSSQL")))
{
var P = new DynamicParameters();
P.Add("UserName", model.UserName);
P.Add("EmailAddress", model.EmailAddress);
P.Add("PhoneNumber", model.PhoneNumber);
P.Add("CommentBox", model.CommentBox);
P.Add("CreateDate", model.CreateDate);
P.Add("ScreenShot", model.ScreenShot);
P.Add("Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);
model.ScreenShot = P.Get<Image>("@ScreenShot");
connection.Execute("dbo.spInterReportTable_Insert1", P, commandType: CommandType.StoredProcedure);
model.Id = P.Get<int>("@Id");
return model;
}
I am experiencing the exception being thrown at connection.Execute
I am fairly new to C# and to coding in general, and I am sorry if I'm unintentionally vague here.
User contributions licensed under CC BY-SA 3.0