我在本地拥有图像,我需要将它们转换为二进制格式并将它们存储在我的SQL Server数据库中,并且应该能够从SSRS报告中访问它们。
请帮我解决这个问题。
答案 0 :(得分:0)
将图像转换为使用File Upload
上传的二进制字节,如
(byte[])fileuploader.FileBytes
并将其作为参数发送到SQL Server
在SSRS
报告中,执行以下步骤
Image Properties
Image Properties
窗口中,选择select image source as:
Database
<强>加成强>
按照以下步骤从数据库中存储和检索客户的徽标图像,并在SSRS
报告中显示
1.将使用File Upload
Control上传的客户端的徽标图像转换为
(byte[])fileuploader.FileBytes
2.将其作为插入命令或存储过程的参数传递给客户端的其他详细信息,如
Create Table Client_Details
{
PK_ClientID int Identity(1,1),
Client_Name Varchar(250),
Client_Address Varchar(750),
Client_Logo Varbinary(max),
Last_insDate datetime
}
PK_Clientid
表中检索Client_Details
并将其存储在Session
变量中,并将Session["PK_Clientid"]
作为Clientid
参数传递到SSRS
报告以检索客户详细信息以及客户的徽标图像,并在上面提到的报告中显示答案 1 :(得分:0)
最初发布图片时确保表单是enctype =&#34; multipart / form-data&#34;。 然后捕获文件并将其转换为byte [],如下面的服务中所示,然后将其插入SQLSERVER
var FileStream=Request.Files;
byte[] bytesInStream = new byte[FileStream[0].InputStream.Length];
FileStream[0].InputStream.Read(bytesInStream, 0, bytesInStream.Length);
再次检索时,需要将其转换为base64字符串并传递给图像标记
<img src="data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAABkAAD/9sAhAABAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAgICAgICAgICAgIDAwMDAwMDAwMDAQEBAQEBAQIBAQICAgECAgMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwP/wAARCADIAMgDAREAAhEBAxEB/8QAvwAAAQQDAQEBAQAAAAAAAAAABwUGCAkDBAoCAQALAQABBQEBAQEAAAAAAAAAAAAEAQIDBQYABwgJEAABBAECBAQDBQYEBgMAAwABAgMEBQYRBwAhEggxQRMJUWEUcYGRIhXwobHBMiPxQhYK0eFiJCUXUnIzgkMYEQABAwIEAwUEBwYEBQIHAAABEQIDAAQhMRIFQVFhcYEiEwbwkaEyscHRQlIjFOHxYnIVB4KSMySiwlNjFrII0kNzgzRFF//aAAwDAQACEQMRAD8ApKr6MEIARoORPLT8dfnx6+mNePgAUQ6nH9QjVOnmTp4afd58QP0r4USuwzokVVEj8o9MHUDyGvh5ajQDhtJRQp8aQrp0aCjy05fsOXCHDOnhrQFOa5UW6TECeklryH+XkR/Phik1KIgcqKNXiSB0EN6a8ydBoOfn5DhheB208QtoiVeJeB9LkNOfTprr8PDy4jc8noKk0jM0+4eHhfT1I0+RT5D4cuZ0+3hlLpBKAY07YWGJIAS0NVfLn93L+XDC7uNPDEK0uN4Z6eieknQ/DT+J8uGF5IpdIpyRMW0aAUggDkfHUfDXTThhNODRSkxjLfXr6RJ+emvz0++F79RqKDWPyYjIdVVSOtmQ0uI62XowKT6S1lKSEEDiJll6oBAjv4ngHN0IUnHMH91OfLsDgS+3uGEjJsrgAoGSLWxE7tPYkt1SGLD2rN+sbjpdD8aTjHcdHFk/">
<img src="data:image/jpeg;base64,StringHere" >