1
我可以使用這個功能在C#中獲取圖像的二進制如何獲得二值圖像中SQL
public static byte[] ImageToBinary(string imagePath)
{
var fileStream = new FileStream(HttpContext.Current.Server.MapPath("~/" + imagePath), FileMode.Open, FileAccess.Read);
var buffer = new byte[fileStream.Length];
fileStream.Read(buffer, 0, (int)fileStream.Length);
fileStream.Close();
return buffer;
}
但我需要做出同樣的SQL
我用這個查詢
(SELECT * FROM OPENROWSET(BULK N'C:\Users\0000001_computers_415.jpeg', SINGLE_BLOB) AS CategoryImage)
但我得到一個錯誤:
Msg 4861, Level 16, State 1, Line 1
Cannot bulk load because the file "C:\Users\0000001_computers_415.jpeg" could not be opened. Operating system error code 3(The system cannot find the path specified.).
文件是否存在於正在運行查詢的數據庫服務器上的該路徑上? – MattC
您確定要讓SQL Server從磁盤讀取映像嗎?我希望無論是調用數據庫,無論是Web應用程序,計劃任務,服務還是其他,應該可以打開圖像文件。 –
只是爲了確定。您正在從正在複製到文件的同一臺計算機上運行查詢,是否正確?我注意到你在別處發佈關於鏈接服務器的問題。 – MattC