473,320 Members | 1,930 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,320 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,
neither attribute SqlProcedure.
Do you know how to write it correctly?
Thank you very much!
/RAM/
Jul 7 '06 #1
2 3010
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
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 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...
13
by: Thom Little | last post by:
My first ASP.NET application on Visual Studio 2005 and .NET Framework 2.0 The application compiles and executes correctly on the development machine. I then publish it to an empty directory on...
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....
1
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.