Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用字符串中的图像位置在sql server 2008中存储图像_C#_Sql Server 2008 - Fatal编程技术网

C# 使用字符串中的图像位置在sql server 2008中存储图像

C# 使用字符串中的图像位置在sql server 2008中存储图像,c#,sql-server-2008,C#,Sql Server 2008,我有一个位置图像 string Imageloc = C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures\\Sunset.jpg 我使用下面的查询在DB中插入图像 "UPDATE Employee SET Image = '(SELECT * FROM OPENROWSET(BULK N'" + Imageloc + "', SINGLE_BLOB) as Image)' WHERE Em

我有一个位置图像

string Imageloc = C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures\\Sunset.jpg
我使用下面的查询在DB中插入图像

"UPDATE Employee SET Image = '(SELECT * FROM OPENROWSET(BULK N'" + Imageloc + "', SINGLE_BLOB) as Image)' WHERE EmployeeID = (SELECT MAX(EmployeeID) FROM Employee";
我得到以下例外

Incorrect syntax near '\\'.\r\nIncorrect syntax near 'Employee'
请告诉我怎么解决。。。我不知道如何将字符串中的
'\\'
替换为
'\'

您的意思是:

"UPDATE Employee SET Image = 
  '(SELECT * FROM OPENROWSET(BULK N'" + Imageloc + "', SINGLE_BLOB) as Image)' 
    WHERE EmployeeID = (SELECT MAX(EmployeeID) FROM Employee)";
                                                            ^
对现在它说“不能隐式地从varchar转换为varbinary(max)”是的。。。现在它说“不能隐式地从varchar转换为varbinary(max)”