SQL CLR UDF

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • songstre

    SQL CLR UDF

    am currently trying to write a very simple UDF that checks for the
    existence of a file. If the file does not exist it should return
    null.
    It doesn't seem to see the file even when it exists, however. I've
    checked and rechecked and the file is there. HELP!
    I tried using both UNC and mapped drive.

    [Microsoft.SqlSe rver.Server.Sql Function(DataAc cess =
    DataAccessKind. Read, SystemDataAcces s = SystemDataAcces sKind.Read)]


    [System.Security .Permissions.Pr incipalPermissi on(System.Secur ity.Permission­
    s.SecurityActio n.Demand)]
    public static SqlString GetPictureUrl(s tring accountName)
    {
    try
    {
    if (accountName == null || accountName == string.Empty)
    return SqlString.Null;
    else if (System.IO.File .Exists(@"Y:\Hr \OurPeople\Whos Who
    \photos\big\" + aname + ".jpg"))
    return new SqlString("http ://mh000xsiis01/hr/
    ourpeople/
    whoswho/photos/big/" + aname + ".jpg");
    else
    return SqlString.Null;


    }
    catch (Exception exc)
    {


    throw exc;
    }
    }


Working...