2.0: writing assembly for SQL Server 2005

R

R.A.M.

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/
 
G

Guest

Did you add reference to the System.Data.dll?

R.A.M. said:
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
 
M

Michael Nemtsev

Hello Michael,

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

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

MN> Did 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
MN> do 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
 

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