Tutorials
Resources
Forum
Reviews
Communities
Interview
Jobs
Projects
Training
Your
Ad
Here
Silverlight Games
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Polls
|
Revenue Sharing
|
Lobby
|
Gift Shop
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
Pawan
(35)
Deepika Harida...
(32)
Nadheera V
(30)
Last 7 Days
Nikhil Gaur
(598)
Anil Kumar ...
(582)
Abhisek Panda
(451)
more...
Resources
»
Articles
»
.NET Framework
»
Exploit .NET Support in Yukon
Posted Date: 02 Oct 2004
Resource Type:
Articles
Category:
.NET Framework
Author:
kalyan kamesh
Member Level:
Bronze
Rating:
Points
: 5
VB.NET Use SqlPipe in a .NET Stored Procedure
Listing 1 This simple stored procedure executes a parameterized query and returns the results through SqlPipe. You use the SqlContext class' static methods to obtain a SqlCommand instance in the current batch, then fill in parameters as you'd do with SqlClient. The SqlContext.GetPipe method obtains a pipe to the current TDS output stream.
' uses SqlDataReader and
' returns results via SqlPipe
_
Public Shared Sub getAuthorsByState( _
ByVal state As SqlString)
' get SqlCommand from context
Dim cmd As SqlCommand
cmd = SqlContext.GetCommand()
' set the text and parameters
cmd.CommandText = _
"select * from authors where state = _
@state"
cmd.Parameters.Add( _
"@state", SqlDbType.VarChar)
cmd.Parameters(0).Value = state
' call ExecuteReader
Dim rdr As SqlDataReader
rdr = cmd.ExecuteReader()
' send back the reader through SqlPipe
' SqlPipe is only available through context
Dim pipe As SqlPipe = SqlContext.GetPipe()
pipe.Send(rdr)
End Sub
****************c# sample**************************
using System;
using System.Data;
using System.Data.Sql;
using System.Data.SqlServer;
using System.Data.SqlTypes;
public class Procs
{
// uses SqlDataReader and returns results via SqlPipe
[SqlProcedure]
public static void getAuthorsByState(SqlString state)
{
SqlCommand cmd = SqlContext.GetCommand();
cmd.CommandText = "select * from authors where state = @state";
cmd.Parameters.Add("@state", SqlDbType.VarChar);
cmd.Parameters[0].Value = state;
SqlDataReader rdr = cmd.ExecuteReader();
SqlPipe pipe = SqlContext.GetPipe();
pipe.Send(rdr);
}
}
**********************************************************************
/////////////////////////////vb sample/////////////////////////////////////////
Imports System
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlServer
Imports System.Data.SqlTypes
Public Class Procs
' uses SqlDataReader and returns results via SqlPipe
_
Public Shared Sub getAuthorsByState(ByVal state As SqlString)
Dim cmd As SqlCommand = SqlContext.GetCommand()
cmd.CommandText = "select * from authors where state = @state"
cmd.Parameters.Add("@state", SqlDbType.VarChar)
cmd.Parameters(0).Value = state
Dim rdr As SqlDataReader = cmd.ExecuteReader()
Dim pipe As SqlPipe = SqlContext.GetPipe()
pipe.Send(rdr)
End Sub
End Class
Responses
No responses found. Be the first to respond and make money from
revenue sharing program
.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
to add tags.
(No tags found.)
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
How to restrict a program to a single instance
Previous Resource:
Converting from Binary to Integer and Integer to Binary
Return to Discussion Resource Index
Post New Resource
Category:
.NET Framework
Post resources and
earn money
!
Related Resources
Model Driven Architecture (MDA)
OverView of Assemblies
Event Log Creation
Calling Com Components from .Net Application
Difference b/w 'Dim obj as Emp' and Dim obj as New Emp
Singleton Class.
dotNet Slackers
About Us
Contact Us
Privacy Policy
Terms Of Use