Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / April 2006

Tip: Looking for answers? Try searching our database.

Cannot compile the following code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nick - 18 Apr 2006 19:34 GMT
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(FillRowMethodName = "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;
   }
};
Carl Daniel [VC++ MVP] - 18 Apr 2006 21:01 GMT
> Seems the FillRowMethodName  caused the problem?
> C# works. but not C++?
[quoted text clipped - 25 lines]
>    }
> };

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
nick - 18 Apr 2006 21:19 GMT
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::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;
   }
};

> > Seems the FillRowMethodName  caused the problem?
> > C# works. but not C++?
[quoted text clipped - 31 lines]
>
> -cd
Marcus Heege - 19 Apr 2006 06:33 GMT
> Thanks, yes, i forgot using the namespace. However, the code still cannot
> be
[quoted text clipped - 36 lines]
>    }
> };

try this

   [SqlFunction(FillRowMethodName = "FillRow")]

instead of this

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

Marcus

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.