I got the following error:
Error 1 error C2597: illegal reference to non-static member
'Microsoft::SqlServer::Server::SqlFunctionAttribute::FillRowMethodName'
when compiling
#include "stdafx.h"
using namespace System;
using namespace System::Data;
using namespace System::Data::Sql;
using namespace System::Data::SqlTypes;
using namespace Microsoft::SqlServer::Server;
using namespace System::Collections;
// select dbo.MyUDF()
// go
public ref class AddNewUDF
{
public:
[SqlFunction(SqlFunctionAttribute::FillRowMethodName = "FillRow")]
static IEnumerable^ MyUDF()
{
SqlTypes::SqlString Value(L"Hello");
DataTable dt;
dt.Rows->Add("");
return dt.Rows;
}
static void FillRow(Object obj, SqlChars^ message, SqlChars^ category,
long^ instanceId)
{
message = gcnew SqlChars("Test");
category = gcnew SqlChars("Test");
instanceId = 123;
}
};
Btw, what's the least cost way to return a one line IEnumerable object?
Marcus Heege - 19 Apr 2006 07:42 GMT
>I got the following error:
>
[quoted text clipped - 34 lines]
> }
> };
try this
[SqlFunction(FillRowMethodName = "FillRow")]
instead of this
[SqlFunction(SqlFunctionAttribute::FillRowMethodName = "FillRow")]
Marcus
Kim Gräsman - 19 Apr 2006 07:44 GMT
Hi nick,
> Error 1 error C2597: illegal reference to non-static member
> 'Microsoft::SqlServer::Server::SqlFunctionAttribute::FillRowMethodName
[quoted text clipped - 3 lines]
>
> [SqlFunction(SqlFunctionAttribute::FillRowMethodName = "FillRow")]
Have you tried not qualifying the named argument? Like so:
[SqlFunction(FillRowMethodName = "FillRow")]
I haven't played with this myself, so this may be hogwash, but it looks like
it's the type qualification that's bothering the compiler.
--
Best regards,
Kim Gräsman