473,388 Members | 1,417 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,388 software developers and data experts.

2.0: writing assembly for SQL Server 2005

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/
Jul 7 '06 #1
1 1172
Hi RAM,

The correct namespaces are:

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

HTH

"R.A.M." <r_********@poczta.onet.plwrote in message
news:5i********************************@4ax.com...
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/

Jul 8 '06 #2

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

Similar topics

3
by: Jaime Stuardo | last post by:
Hi all... I have an ASP.NET 2.0 application. This application uses 2 components, named Informe.dll and Seguridad.dll, whose source codes are under the same solution as the ASP.NET application....
2
by: Eric Falsken | last post by:
Eric Falsken <eric@db4o.com> wrote on 04 Dec 2005: > craigkenisston@hotmail.com wrote on 19 Nov 2005: > >> I'm working in the migration of an asp.net application in 1.1 to 2.0. >> I'm new to...
1
by: urs | last post by:
Two days ago, I built an ASP.NET 2.0 application and published it on a shared IIS 6 Web server. After publishing, and during the whole day, it worked fine. The server remained untouched since....
2
by: R.A.M. | last post by:
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...
1
by: R.A.M. | last post by:
Hello, I am learning SQL Server 2005. I have (correctly) written in .NET assembly DemoSQLServer with aggregate function AvgNoMinMax in class Demo and I have added assembly to database...
2
by: Jeff | last post by:
Hey asp.net 2.0 My asp.net 2.0 project has got a assembly load problem: Some of my web.config settings: <membership defaultProvider="AH_MembershipProvider" userIsOnlineTimeWindow="15">
5
by: =?Utf-8?B?TWFydHluIEZld3RyZWxs?= | last post by:
From the amount of articles about this one I’m sure this gets asked a lot, but I haven’t yet found a succinct article which explains what is required in its entirety. I work using Visual...
1
by: divya | last post by:
Hi, I made an assembly (class library project) in Dot net and wanted the assembly to have COM interoperability successfully got the assembly working with VB6 performing following steps: 1.Create...
3
by: Amber | last post by:
I have created a C# library containing CLR stored procedures and user- define functions using Visual Studio 2005, and I have used Visual Studio to deploy the assembly to a SQL Server 2005 instance...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.