2014-10-16 74 views

回答

0

轉換使用File Upload

(byte[])fileuploader.FileBytes 

上傳的圖片爲二進制字節,並在SQL Server

把它作爲參數傳遞給Insert命令或存儲過程在你SSRS報告執行以下步驟

  1. 在報告中插入圖片
  2. 右鍵點擊圖片,選擇Image Properties
  3. Image Properties窗口中選擇select image source as:Database

加成

按照以下步驟用於存儲和檢索客戶的徽標圖像來自數據庫並在SSRS報告中顯示它

1.Convert的上傳使用File Upload控制成字節狀

(byte[])fileuploader.FileBytes 

2.Pass它作爲參數傳遞給插入的命令或存儲過程與客戶的其他細節等

一個表客戶的標誌圖像
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 
} 
  • 檢索來自Client_DetailsPK_Clientid基於誰登錄客戶端,並將其存儲在變量SessionSession["PK_Clientid"]作爲Clientid參數傳遞到SSRS報告檢索客戶的詳細資料,以及客戶端的標誌形象,正如我上面
  • +0

    我應該能夠根據我登錄的客戶端獲得客戶的標識。我不假設在rdl文件中添加圖像。 – 2014-10-17 03:28:38

    +0

    這與我們在項目中做的情景是一樣的,在數據​​庫中將客戶端的Logo圖像作爲字節與客戶端的其他細節添加到PK_CLIENTID中,並通過將PK_CLIENTID傳遞給客戶端的Logo圖像你的'SSRS'報告作爲參數'PK_CLIENTID'是基於登錄在我們網站上的客戶端不要忘記你的數據庫表中的'PK_CLIENTID'對於獲取信息非常重要 – Rajesh 2014-10-17 04:04:45

    0

    提到最初發布圖片時,請確保形式是ENCTYPE =「的multipart/form-data的顯示它在報告」。 再搭上文件,並將其轉換爲byte []作爲您的服務如下圖所示,然後將其插入到SQLSERVER

    var FileStream=Request.Files; 
    byte[] bytesInStream = new byte[FileStream[0].InputStream.Length]; 
    FileStream[0].InputStream.Read(bytesInStream, 0, bytesInStream.Length); 
    

    而再次retreiving你需要將其轉換爲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" > 
    
    相關問題