illegal reference to non-static member?

G

Guest

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?
 
M

Marcus Heege

nick said:
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;
}
};

try this

[SqlFunction(FillRowMethodName = "FillRow")]

instead of this

[SqlFunction(SqlFunctionAttribute::FillRowMethodName = "FillRow")]

Marcus
 
?

=?iso-8859-1?Q?Kim=20Gr=e4sman?=

Hi nick,
Error 1 error C2597: illegal reference to non-static member
'Microsoft::SqlServer::Server::SqlFunctionAttribute::FillRowMethodName
' when compiling

[...]

[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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top