473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Cannot compile the following code

Seems the FillRowMethodName caused the problem?
C# works. but not C++?

using namespace System;
using namespace System::Data;
using namespace System::Data::Sql;
using namespace System::Data::SqlTypes;
using namespace Microsoft::SqlServer::Server;

public ref class AddNewUDF
{
public:
[Microsoft::SqlServer::Server::SqlFunction(FillRowM ethodName = "FillRow")]
static IEnumerable MyUDF()
{
// Put your code here
SqlTypes::SqlString Value(L"Hello");
return Value;
}

static void FillRow(Object obj, SqlChars^ message, SqlChars^ category,
long^ instanceId)
{
message = gcnew SqlChars("Test");
category = gcnew SqlChars("Test");
instanceId = 123;
}
};
Apr 18 '06 #1
3 1263
"nick" <ni**@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
Seems the FillRowMethodName caused the problem?
C# works. but not C++?

using namespace System;
using namespace System::Data;
using namespace System::Data::Sql;
using namespace System::Data::SqlTypes;
using namespace Microsoft::SqlServer::Server;

public ref class AddNewUDF
{
public:
[Microsoft::SqlServer::Server::SqlFunction(FillRowM ethodName =
"FillRow")]
static IEnumerable MyUDF()
{
// Put your code here
SqlTypes::SqlString Value(L"Hello");
return Value;
}

static void FillRow(Object obj, SqlChars^ message, SqlChars^ category,
long^ instanceId)
{
message = gcnew SqlChars("Test");
category = gcnew SqlChars("Test");
instanceId = 123;
}
};


You need to add #using <system.data.dll> so that those namespaces are
visible to the compiler. I think you can add a reference at the project
level instead, but I can't check that right now.

-cd
Apr 18 '06 #2
Thanks, yes, i forgot using the namespace. However, the code still cannot be
compiled:

Error 1 error C2597: illegal reference to non-static member
'Microsoft::SqlServer::Server::SqlFunctionAttribut e::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::FillRowMethodNam e = "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;
}
};
"Carl Daniel [VC++ MVP]" wrote:
"nick" <ni**@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
Seems the FillRowMethodName caused the problem?
C# works. but not C++?

using namespace System;
using namespace System::Data;
using namespace System::Data::Sql;
using namespace System::Data::SqlTypes;
using namespace Microsoft::SqlServer::Server;

public ref class AddNewUDF
{
public:
[Microsoft::SqlServer::Server::SqlFunction(FillRowM ethodName =
"FillRow")]
static IEnumerable MyUDF()
{
// Put your code here
SqlTypes::SqlString Value(L"Hello");
return Value;
}

static void FillRow(Object obj, SqlChars^ message, SqlChars^ category,
long^ instanceId)
{
message = gcnew SqlChars("Test");
category = gcnew SqlChars("Test");
instanceId = 123;
}
};


You need to add #using <system.data.dll> so that those namespaces are
visible to the compiler. I think you can add a reference at the project
level instead, but I can't check that right now.

-cd

Apr 18 '06 #3
"nick" <ni**@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
Thanks, yes, i forgot using the namespace. However, the code still cannot
be
compiled:

Error 1 error C2597: illegal reference to non-static member
'Microsoft::SqlServer::Server::SqlFunctionAttribut e::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::FillRowMethodNam e = "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::FillRowMethodNam e = "FillRow")]

Marcus
Apr 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Alex Ang | last post by:
I have written the following VBScript program. It is stored into a file "map_drive.vbs". It successfully mapped to a network drive \\server1\data. Dim WshNetwork Set WshNetwork =...
5
by: Brad Moore | last post by:
Hey all, I'm getting the following compiler error from my code. I was wondering if anyone could help me understand the concept behind it (I actually did try and compile this degenerate...
8
by: Vijay | last post by:
Hi all, Im using gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-20) on 64bit linux server im trying to compile following code --------------------sam.cpp--------------------- #include...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
2
by: mudge | last post by:
Hi, I'm getting some very strange problems with some C# code. We're running an ASP.NET application on a local server in a DMZ. If I access it using the internal address, the application works...
4
by: newbie120 | last post by:
Hi all maybe its just been a long day, but i have a question about call access modifiers in C#. Consider the following code. namespace Application { private class Class1 { int i;
13
by: hn.ft.pris | last post by:
Hi: I have the following simple program: #include<iostream> using namespace std; int main(int argc, char* argv){ const double L = 1.234; const int T = static_cast<const int>(L); int arr;
5
by: wong_powah | last post by:
#include <vector> #include <iostream> using std::cout; using std::vector; enum {DATASIZE = 20}; typedef unsigned char data_t;
1
by: prakash.mirji | last post by:
Hello, I am trying to compile C++ code which uses rogue wave 9.0 classes on RHEL 4.0. I use gnu g++ compiler to compile the code. Compiler is not able to match the right type of parameters to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.