By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,560 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

2.0: writing assembly for SQL Server 2005

P: n/a
Hello,
I am learning .NET 2.0. I need to write an assembly to be added to SQL
Server 2005 database DemoSQLServer, with stored procedures. According
to one of my books I wrote (Demo.cs):

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Sql;
using System.Data.SqlServer;
using System.Data.SqlTypes;

namespace DemoSQLServer
{
public class Demo
{
[SqlProcedure]
public static int GetNumberOfBooks()
{
SqlCommand cmd = SqlContext.GetCommand();
cmd.CommandText = "SELECT COUNT(*) AS 'Number of books'
FROM Books;";
return (int) cmd.ExecuteScalar();
}
}
}

(I have a table DemoSQLServer.dbo.Books.)
The problem is that I cannot build my assembly because MS Visual C#
Express Edition does not recognize namespace System.Data.SqlServer,
neither attribute SqlProcedure.
Do you know how to write it correctly?
Thank you very much!
/RAM/
Jul 7 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Did you add reference to the System.Data.dll?

"R.A.M." wrote:
Hello,
I am learning .NET 2.0. I need to write an assembly to be added to SQL
Server 2005 database DemoSQLServer, with stored procedures. According
to one of my books I wrote (Demo.cs):

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Sql;
using System.Data.SqlServer;
using System.Data.SqlTypes;

namespace DemoSQLServer
{
public class Demo
{
[SqlProcedure]
public static int GetNumberOfBooks()
{
SqlCommand cmd = SqlContext.GetCommand();
cmd.CommandText = "SELECT COUNT(*) AS 'Number of books'
FROM Books;";
return (int) cmd.ExecuteScalar();
}
}
}

(I have a table DemoSQLServer.dbo.Books.)
The problem is that I cannot build my assembly because MS Visual C#
Express Edition does not recognize namespace System.Data.SqlServer,
neither attribute SqlProcedure.
Do you know how to write it correctly?
Thank you very much!
--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

Jul 7 '06 #2

P: n/a
Hello Michael,

Uuups, sorry it's not the point. Mistyped.

see there http://msdn2.microsoft.com/en-us/library/ms160847.aspx

MNDid you add reference to the System.Data.dll?
MN>
MN"R.A.M." wrote:
MN>
>Hello,
I am learning .NET 2.0. I need to write an assembly to be added to
SQL
Server 2005 database DemoSQLServer, with stored procedures. According
to one of my books I wrote (Demo.cs):
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Sql;
using System.Data.SqlServer;
using System.Data.SqlTypes;
namespace DemoSQLServer
{
public class Demo
{
[SqlProcedure]
public static int GetNumberOfBooks()
{
SqlCommand cmd = SqlContext.GetCommand();
cmd.CommandText = "SELECT COUNT(*) AS 'Number of books'
FROM Books;";
return (int) cmd.ExecuteScalar();
}
}
}
(I have a table DemoSQLServer.dbo.Books.)
The problem is that I cannot build my assembly because MS Visual C#
Express Edition does not recognize namespace System.Data.SqlServer,
neither attribute SqlProcedure.
Do you know how to write it correctly?
Thank you very much!
MN"At times one remains faithful to a cause only because its opponents
MNdo not cease to be insipid." (c) Friedrich Nietzsche
MN>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Jul 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.