Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
declare @result varchar(max)
set @result=(SELECT * FROM tbroomtype FOR XML
raw('Room_info'), root('Roomtypes'))
print @result
 exec [dbo].[xp_SaveXML] @result,'c:\temp\myxml.xml'




hi i m using clr to save the xml content into the specified file . ..
when i m running this above query it is giving me following error :

Error writing to file Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

i m using .net 2008 and mssql 2008

can any help me???
thanks
Posted

What is xp_SaveXML?

There is a chance that your problem is there, although without seeing the code it is difficult to be sure.

Does the user running your code have permissions to create a file in c:\Temp?
 
Share this answer
 
i jst add the read write permission to the directory
..
and xp_saveXml is my clr stored procedure

MSIL
[Microsoft.SqlServer.Server.SqlProcedure]
   public static void xp_SaveXML(string  XmlData, String Filename)
   {
       try
       {
           FileIOPermission(FileIOPermissionAccess.AllAccess, Filename);
           PermissionSet(PermissionState.Unrestricted);
           ps.AddPermission(fp);
           File.WriteAllText(Filename, XmlData);
           XmlDocument xmlDoc = new XmlDocument();
           SqlPipe output = SqlContext.Pipe;
           xmlDoc.LoadXml(XmlData);
           xmlDoc.Save(Filename);
       }
       catch (Exception ex)
       {
           SqlContext.Pipe.Send("Error writing to file " + ex.Message);
       }
   }


....
it i think related to mu assebly strong name problem .. . as my assembly created from clr stored procedure is not assigned a strong name ....uh i m jst thinking of that all i m not sure about all this
....

can u plz go through this..?


thanks for reply
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900