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.
Do you know how to write it correctly?
Thank you very much!
/RAM/
 
D

Dave Sexton

Hi RAM,

The correct namespaces are:

using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;
using System.Data.SqlClient;

HTH
 

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