How To Read The Return Value Of A Stored Procedure?

Aug 6, 2007


Stored procedure in SQL Server 2K is as follows..

CREATE PROCEDURE TestDataRead
@TestString varchar(20) OUTPUT
AS

SET @TestString = 'Mr.String'
GO
-----------------------------------------------------------------------
SSIS package details.

OLEDB connection manager; Connection works fine.
Execute SQL Task Editor properties are as follows.
ResultSetà None
SQLStatementà exec TestDataRead
SQLSourceTypeirectInput
Parameter Mapping:
VariableName: selected the user variable from the list.
Direction: Output
DataType:varchar
Parameter Name: 0
Parameter Type: 20
When I run I am getting the following error.



SSIS package "TEST SSIS1.dtsx" starting.
Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "exec TestDataRead" failed with the following error: "Procedure 'TestDataRead' expects parameter '@TestString', which was not supplied.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. ...........................................
...................................................................



Please help.
Smith

View 3 Replies


ADVERTISEMENT

Read Stored Procedure Return

May 19, 2008

Hi,Using Chandu Thota's book Mappoint.net I attempted to set up a findnearby query using his example Implementing Spatial Search Using SQL Server.
The book uses C# I have attempted to convert the code to call the stored procedure as follows:
TryDim units As Int16 = 0
Dim cmd As SqlCommand = New SqlCommand("FindNearby")
'Assign input values to the sql command
cmd.CommandType = CommandType.StoredProcedurecmd.Parameters.AddWithValue("@CenterLat", latitude)
cmd.Parameters.AddWithValue("@CenterLon", longitude)cmd.Parameters.AddWithValue("@SearchDistance", distance)
cmd.Parameters.AddWithValue("@Units", units)Dim con As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("VehicleMarshallConnectionString").ConnectionString)
If con.State = ConnectionState.Closed Then con.Open()
If con.State = ConnectionState.Open Then
cmd.Connection = conDim dreader As SqlDataReader = cmd.ExecuteReader()
If dreader.Read() Then
If Not dreader.IsDBNull(1) ThenDim ordnum As String = dreader(1).ToString
End If
End If
End IfIf con.State = ConnectionState.Open Then con.Close()
Catch ex As Exception
Finally
End Try
 
The code returns no values but when I execute the stored procedure from the server explorer in visual studio I get the records I would expect in the output window. How would I read the returned values from my code.
Output Window
Running [dbo].[FindNearby] ( @CenterLat = 53.10531, @CenterLon = -2.4769, @SearchDistance = 100, @Units = 0 ).
ID ordnum ProxDistance
----------- ------------------------- -------------------------
1 009999/USP 0
2 109999/USP 14.5971373147639
3 119999/USP 57.7144756947325
No rows affected.
(3 row(s) returned)
@RETURN_VALUE = 0
Finished running [dbo].[FindNearby].
Regards,
JoeBo

View 10 Replies View Related

Return Error Code (return Value) From A Stored Procedure Using A Sql Task

Feb 12, 2008


I have a package that I have been attempting to return a error code after the stored procedure executes, otherwise the package works great.

I call the stored procedure from a Execute SQL Task (execute Marketing_extract_history_load_test ?, ? OUTPUT)
The sql task rowset is set to NONE. It is a OLEB connection.

I have two parameters mapped:

tablename input varchar 0 (this variable is set earlier in a foreach loop) ADO.
returnvalue output long 1

I set the breakpoint and see the values change, but I have a OnFailure conditon set if it returns a failure. The failure is ignored and the package completes. No quite what I wanted.

The first part of the sp is below and I set the value @i and return.


CREATE procedure [dbo].[Marketing_extract_history_load_TEST]

@table_name varchar(200),

@i int output

as

Why is it not capturing and setting the error and execute my OnFailure code? I have tried setting one of my parameter mappings to returnvalue with no success.

View 2 Replies View Related

T-SQL (SS2K8) :: One Stored Procedure Return Data (select Statement) Into Another Stored Procedure

Nov 14, 2014

I am new to work on Sql server,

I have One Stored procedure Sp_Process1, it's returns no of columns dynamically.

Now the Question is i wanted to get the "Sp_Process1" procedure return data into Temporary table in another procedure or some thing.

View 1 Replies View Related

Using A Stored Procedure To Query Other Stored Procedures And Then Return The Results

Jun 13, 2007

Seems like I'm stealing all the threads here, : But I need to learn :) I have a StoredProcedure that needs to return values that other StoredProcedures return.Rather than have my DataAccess layer access the DB multiple times, I would like to call One stored Procedure, and have that stored procedure call the others to get the information I need. I think this way would be more efficient than accessing the DB  multiple times. One of my SP is:SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived,     I.Expired, I.ExpireDate, I.Deleted, S.Name AS 'StatusName', S.ItemDetailStatusID,    S.InProgress as 'StatusInProgress', S.Color AS 'StatusColor',T.[Name] AS 'TypeName',    T.Prefix, T.Name AS 'ItemDetailTypeName', T.ItemDetailTypeID    FROM [Item].ItemDetails I    INNER JOIN Item.ItemDetailStatus S ON I.ItemDetailStatusID = S.ItemDetailStatusID    INNER JOIN [Item].ItemDetailTypes T ON I.ItemDetailTypeID = T.ItemDetailTypeID However, I already have StoredProcedures that return the exact same data from the ItemDetailStatus table and ItemDetailTypes table.Would it be better to do it above, and have more code to change when a new column/field is added, or more checks, or do something like:(This is not propper SQL) SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived,     I.Expired, I.ExpireDate, I.Deleted, EXEC [Item].ItemDetailStatusInfo I.ItemDetailStatusID, EXEC [Item].ItemDetailTypeInfo I.ItemDetailTypeID    FROM [Item].ItemDetails IOr something like that... Any thoughts? 

View 3 Replies View Related

Stored Procedure (possible To Read Txt Files?)

May 21, 2008

Hi
I have decided to approach the problem here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=103310

by using a Stored procedure, someone mentioned it's possible
for a SP to read the contents of a text file ?

IS it ?

For example i have a DB table
with fields to,from,subject,body

problem is the body field references a file (full path)
and i need to extract all info into a txt file
the full txt body, so can i perform some sort of inner
operation on the select body .. part of the SP ?

View 2 Replies View Related

Using Stored Procedure To Read From ODBC ?

Sep 25, 2006

Dear all,

I am using SQL 2000 and would like to dynamically assign ODBC data source to transform data task. Do you have a stored procedure to perform read/write from/to ODBC data source? I would like to input data source and table name.

Thank you and Best regards,

Chaivat

View 5 Replies View Related

Read / Write Into .doc From SQL Stored Procedure

Jun 25, 2007

I need to create a flat file as word document, may i know how to write text from stored procedure if a file is already exist then the text will append, how to do it ?



Thank you.

View 1 Replies View Related

Transact SQL :: Return Set Of Values From SELECT As One Of Return Values From Stored Procedure

Aug 19, 2015

I have a stored procedure that selects the unique Name of an item from one table. 

SELECT DISTINCT ChainName from Chains

For each ChainName, there exists 0 or more StoreNames in the Stores. I want to return the result of this select as the second field in each row of the result set.

SELECT DISTINCT StoreName FROM Stores WHERE Stores.ChainName = ChainName

Each row of the result set returned by the stored procedure would contain:

ChainName, Array of StoreNames (or comma separated strings or whatever)

How can I code a stored procedure to do this?

View 17 Replies View Related

Read Usergroup For A Username With Stored Procedure

Aug 10, 2007

Hi
I wounder if there is a sp in the master db that can give me what usergroup a username is connected to / and or give me info if the username is valid (Windows NT login).
If not: then how do I read what usergroup a username is connected to? sysxlogin table in master db? And can I connect to a sp in master db from another db? Can I create a sp in my db that reads in the master db?
Thanks!!
 Best Regards
Staffan

View 1 Replies View Related

Stored Procedure Hanging In Read Only Database...

May 7, 2001

Problem Description:

Stored Procedure hanging when try to execute in READ_ONLY Database. Though the stored procedure is highly complicated,it runs smoothly on the same server if the Database option is set to READ/WRITE. Not all stored procedures are hanging in READ_ONLY database,only if the stored procedure tries to retrieve more records (say 10000 ).

If the SQL Statements present inside the stored procedures are executed,they are getting executed perfectly but hangs if it is executed as stored procedure.

On restarting the SQL Server, stored procedure getting executed only for the first time in READ_ONLY database but executing it again for the second time, it starts hanging. ( I tried executing the stored procedure after clearing the procedure cache but still hangs ).

Environment:

Windows NT 4.0 (Service Pack 5 )
SQL Server 7.0 ( Service Pack 3 )
Multi Processor ( 2 - 500 Mhz )

Let me know if you need more information on it.

View 3 Replies View Related

Create And Read A Table From A Stored Procedure

Nov 25, 2001

In a stored procedure, I am trying to create a table and then read it from within that SP or from another one (nestsed). When I run the below code (simplified version of my real SP), no records are returned even though I know that there is data. The table is created and records are inserted, I just cannot read the records from the SP or one that calls it with an EXEC.

Any ideas? My code is listed below. (When I get this to work, I plan to convert the code to manipulate a temporaty table).

Alter Procedure spWod_rptWoStatusSummary_9

As
BEGIN
CREATE TABLE tblStatusSummary (TckStaffCd_F Char(3), RecType Char(20))
INSERT INTO tblStatusSummary
SELECT TckStaffCd_F, RecType
END

BEGIN
Select * from tblStatusSummary
end

View 1 Replies View Related

Read A Flat File From Stored Procedure.

Jun 27, 2001

Hi,

How to read from a flat file in a stored procedure. Is there any built in utility available ? Please let me know.

Mahesh.

View 2 Replies View Related

Stored Procedure To Read And Write Between XML And SQLServer

Mar 28, 2004

Hi All,
I need some help from you experts.

I need to develop something that reads from xml files and writes in to sqlserver, also it should read from SQLServer and writes to xml.

I should be able to give this as a job to exectue daily ,etc.

Can we do this using stored procedures in SQLServer.
Pls paste some sample code, if any or direct me to any url with better info.

Thanks in advance

View 11 Replies View Related

Using The Return Value From A Stored Procedure In VB

Nov 20, 2007

 Hi guys I know this is a really common question, and I have read loads of replies on it but everything I try does not work.  I have written a small stored procedure in SQL server to upload images to a table and return the new ID using scope_identity.  I have tested it and it works fine.  here it is:*******    @siteID numeric(18,0),    @imgNum numeric(18,0),    @title NVarchar(50),    @MIMEtype nchar(10),    @imageData varbinary(max)ASBEGINSET NOCOUNT ONdeclare @imageID intINSERT INTO [site_images] ([img_siteID], [img_num], [img_title], [img_MIME], [Img_Data]) VALUES (@siteID, @imgNum, @Title, @MIMEType, @ImageData) SET @imageID = SCOPE_IDENTITY()RETURN @imageIDSET NOCOUNT OFF************If I run this in management studio express it runs fine and returns the ID under 'return value'. The problem I have is trying to actually call that return value in VB.  If I try using these lines:Dim returnParam As SqlParameterreturnParam = New SqlParameter("@imageID", SqlDbType.UniqueIdentifier)returnParam.Direction = ParameterDirection.OutputcmdTest.Parameters.Add(returnParam)withcnBKTest.Open()cmdTest.ExecuteNonQuery() imageIDparam = returnParam.value.toStringcnBKTest.Close()  I get the error "procedure has too many arguments specified"And if I try to access the return value like this: imageIDparam = cmdTest.Parameters("@return_value").ValueI get the error "@return_value is not contained by this sqlparametercollection"  What am I doing wrong?  Any help would be greatly appreciated. Robsa         

View 3 Replies View Related

No Return Value From This Stored Procedure

Nov 28, 2007

I have written this stored procedure but I get no return value (neither 0 nor 1). What I hope is when the transaction successful, return value 1. If fails, return value 0.1 set @TransactionOk = 0
2
3 BEGIN TRAN
4
5 UPDATE WhiteList_IMEI SET WhiteList_IMEI_Used = 1, Whitelist_IMEI_UsedDate = getdate()
6 WHERE WhiteList_IMEI_Code = @IMEICode_New
7
8 IF @@ERROR <> 0
9 BEGIN
10 ROLLBACK TRAN
11
12 PRINT ('Error. Contact Software Engineer.')
13 RETURN
14 END
15
16 COMMIT TRAN
17 set @TransactionOk = 1
  

View 6 Replies View Related

Return Value From Stored Procedure

May 16, 2008

Hi,
I have been trying to this this for quite a while with no joy can someone please tell me the error of my ways.  I am trying to add a new record by stored procedure, this I can do, but my problem lies with the returnvalue part of the procedure.  I cannot get it to work. When I debug it tells me that the "Specified cast is not valid" see C# code as i comment the line where it errors.  I enclose a sample stored procedure and its c# code.  Please can someone tell me where I am going wrong? as this is annoying me alot
SQL:create procedure SPUAddVehicleInsert
@VehicleDetailsRegistrationNumber varchar(50),
@VehicleDetailsMake varchar(50),
@VehicleDetailsModel varchar(50),
@NID bigint =null
as
insert into tblvehicledetails
(
VehicleDetailsRegistrationNumber,
VehicleDetailsMake,
VehicleDetailsModel,

)
values
(
@VehicleDetailsRegistrationNumber,
@VehicleDetailsMake,
@VehicleDetailsModel,

);
select @NID = scope_identity();c# code on sqldatasource:  protected void dsAddVehicle_Inserted(object sender, SqlDataSourceStatusEventArgs e)
{
Int64 VID = (Int64)e.Command.Parameters["NID"].Value; //errors with specified cast is invalid

Response.Redirect("details.aspx?VID=" + VID.ToString());

}
protected void dsAddVehicle_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
SqlParameter p = new SqlParameter("NID", SqlDbType.BigInt);
p.Direction= ParameterDirection.ReturnValue;
e.Command.Parameters.Add(p);

sql datasource:<asp:SqlDataSource ID="dsAddVehicle" runat="server" ConnectionString="<%$ ConnectionStrings:National %>"
InsertCommand="SPUAddVehicleInsert" InsertCommandType="StoredProcedure" SelectCommand="SPUAddVehicleSelect"
SelectCommandType="StoredProcedure" OnInserted="dsAddVehicle_Inserted" OnInserting="dsAddVehicle_Inserting">
<InsertParameters>
<asp:Parameter Name="VehicleDetailsRegistrationNumber" Type="String" />
<asp:Parameter Name="VehicleDetailsMake" Type="String" />
<asp:Parameter Name="VehicleDetailsModel" Type="String" />
</InsertParameters>
</asp:SqlDataSource> 

View 4 Replies View Related

Stored Procedure Return Value

Jun 20, 2005

I have a stored procedure that returns an integer value, declared as:Public Function MyProc(..) As Int32   .   .   Return <integer>End FunctionI return an integer value, and can do this and get the value returned from the method, as such:declare @rc intexec @rc = dbo.MyProc <params>select @rcThis returns the value; how do I return the value to code and get the value; I've been debugging and that is my problem, I can't get the value to return.Thanks a lot.

View 2 Replies View Related

Return Value In Stored Procedure

Nov 20, 2005

Hello all of members, I have written a Stored Procedure.that creates a new account and then returns a value witch displays a result to me.if result is 1 "Username already exists" or 2 "E-Mail already exists".I did it with "Return" instruction.But, I don't know how can I get the returned value in ASP.NET(VB.NET)? Please help me. Thanks in advance

View 3 Replies View Related

Getting A Return Value From A Stored Procedure

Nov 25, 2005

Hi all,Is there anyway to get a returned value from a called Stored Procedure from within a piece of SQL? For example, I have the following code...DECLARE @testval AS INTSET @testval = EXEC u_checknew_dwi_limits '163'IF (@testval = 0)BEGIN     PRINT '0 Returned'ENDELSEBEGIN     PRINT '1 Returned'END...which
as you can see calls a SP called 'u_checknew_dwi_limits'. This SP
(u_checknew_dwi_limits) actually returns a value (1 or 0), so I want to
assign that value to the '@testval' variable (as you can see in my
code) - but Query Analyser is throwing an error at me. Is this the
correct way to do this?ThanksTryst

View 2 Replies View Related

How To Get The Return Value Of A Stored Procedure

Apr 28, 2006

I have a Stored procedure (sql 2000), that inserts data into a table. Then, I add this, at the end: Return Scope_Identity()
I have the parameters for the sProc defined and added to the Command, but I'm having a really lousy time trying to figure out how to get the return value of the Stored PRocedure. BTW - I'm using OleDB instead of SQL due to using a UDL for the connection string.
I have intReturn defined as an integer
I've tried :Dim retValParam As OleDbParameter = cmd.Parameters.Add("@RETURN_VALUE", OleDbType.Integer)retValParam.Direction = ParameterDirection.ReturnValueintReturn=cmd.Parameters("@RETURN_VALUE").Value
whenever I add this section - I get an error that there are too many arguments for the sProc.
I've tried:intreturn=cmd.ExecuteNonquery - tried adding a DataReader - using ExecuteScalar - I've tried so many things and gotten so many errors - I've forgotten which formations go with which errors.
What is the best way to do this in the code part (VB.Net)?
Thanks ahead of time

View 2 Replies View Related

Stored Procedure Return Value

May 16, 2006

I don't know whey this code does not return the values when I run it in sql server 2005 manager.set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



ALTER PROCEDURE [dbo].[usp_usr_Add]

@FName nvarchar(30),
@LName nvarchar(30),
@UserName nvarchar(20),
@Password nvarchar(20),
@Email nvarchar(50),
@Country nvarchar(2),
@AIM nvarchar(10)
AS
SET NOCOUNT ON
BEGIN

DECLARE @usrID int
DECLARE @usrEmail int

SELECT @usrID = NULL
SELECT @usrEmail = NULL


SELECT @usrID = usrID FROM usr WHERE usrName = @UserName

IF (@usrID IS NOT NULL )
BEGIN
RETURN 1
END

SELECT @usrEmail = usrID FROM usr WHERE usrEmail = @Email

IF (@usrEmail IS NOT NULL)
BEGIN
RETURN 2
END



INSERT INTO usr (usrFName, usrLName, usrName, usrPassword, usrEmail, usrCountry, usrAIM, usrJoinDt)

VALUES (@FName, @LName, @UserName, @Password, @Email, @Country, @AIM, GetDate())
RETURN 0

END



 When i run this code i executes fine except when the two conditions become true they do not return thier values, nor does it return 0 when it inserts a row.

View 5 Replies View Related

Stored Procedure Return Value.

Oct 17, 2000

Hi

I have the following stored procedure which when exectuted within the Query Analyzer adds a record and returns the @SeqRunNo value. However when I call
it in the from ado the record is added but the value is empty.

I enter the parameter as:

.Parameters.Append .CreateParameter("@SeqRunNo", adVarChar, adParamOutput, 4)

and try and access it as:

SeqRunNo = oCommand.Parameters("@SeqRunNo").Value

Any ideas?

Thanks.


john








CREATE PROCEDURE up_mix_Set_Seq_Run_No
@IID int,
@TrackingID int,
@ADP_Code varchar(6),
@ClientID varchar(20),
@SeqRunNo varchar(4) OUTPUT
AS

DECLARE @Max_Seq_No int,
@Seq_No varchar(4),
@LastUpdate datetime

SELECT @Seq_No = QTR_SEQ_RUN_NO FROM Transmission_Quarter
WHERE IID = @IID
AND Tracking_ID = @TrackingID
AND ADP_Code = @ADP_Code

IF ISNULL(@Seq_No,0) = 0
BEGIN

SET @LastUpdate = GETDATE()

SELECT @Max_Seq_No = CAST(MAX(QTR_SEQ_RUN_NO) AS int)
FROM Transmission_Quarter
WHERE IID = @IID
AND ADP_Code = @ADP_Code

IF ISNULL(@Max_Seq_No,0) = 0
BEGIN
SET @SeqRunNo = '0001'
END
ELSE
BEGIN
IF @Max_Seq_No = 9999
BEGIN
SELECT @SeqRunNo = '0001'
END
ELSE
BEGIN
SELECT @SeqRunNo = REPLICATE('0', 4 - DATALENGTH(CAST(@Max_Seq_No AS VARCHAR))) + CAST((@Max_Seq_No + 1) AS VARCHAR)
END
END

INSERT INTO Transmission_Quarter
(IID, Tracking_ID, QTR_SEQ_RUN_NO, ADP_Code, Last_Updated_By, Last_Updated_Date)
VALUES
(@IID, @TrackingID, @SeqRunNo, @ADP_Code, @ClientID, @LastUpdate)

END
ELSE
BEGIN
SELECT @SeqRunNo = @Seq_No
END

GO

View 2 Replies View Related

Return A Value From Stored Procedure

Mar 27, 2002

How do I get then return value from an insert stored procedure?

for example:


CREATE PROCEDURE sp_ReceiptsInsertc
@Branch_ID int,
@Source varchar(1),
@BatchNo varchar(8),
@Amount money ,
@Iden int OUTPUT
AS

INSERT INTO Receipts(Branch_ID, Source, BatchNo, Amount)
VALUES (@Branch_ID, @Source, @BatchNo, @Amount)

SELECT @Iden=@@Identity
GO


Thanks

View 1 Replies View Related

Return A Value From Stored Procedure

Mar 27, 2002

How do I get then return value from an insert stored procedure?

for example:


CREATE PROCEDURE sp_ReceiptsInsertc
@Branch_ID int,
@Source varchar(1),
@BatchNo varchar(8),
@Amount money ,
@Iden int OUTPUT
AS

INSERT INTO Receipts(Branch_ID, Source, BatchNo, Amount)
VALUES (@Branch_ID, @Source, @BatchNo, @Amount)

SELECT @Iden=@@Identity
GO


Thanks

View 2 Replies View Related

Return Value In A Stored Procedure

Jul 20, 2005

Hello Newsgroup !My Tools are:Windows 2000, VBA(Access 2000) and MS SQL Server 7.0I wrote in an *.adp project (Access 2000) a Stored Procedure "xyz"with parameters a,bIn my VBA Code i wrote:Dim par As New ADODB.ParameterCmd.CommandType = adCmdStoredProcCmd.CommandText = "[prcSucheUNRWIAEStichtag]"Set par = Cmd.CreateParameter("@a", adInteger)Cmd.Parameters.Append parSet par = Cmd.CreateParameter("@b", adVarChar, adParamInput, 5)Cmd.Parameters.Append par........Cmd.Parameters(0) = aCmd.Parameters(1) = bSet rsTemp = Cmd.ExecuteNow my Problem is the following:there is an error in the stored procedure and i want to use something likethis:if @idontknow = '000000000'Beginreturn(1) -- Something <>0endHow can i use this return value in my VBA code ? Maybe i should ask thisquestion in an other Newsgroup. Pleaselet me know in which oneGreetingsFrank

View 2 Replies View Related

Get Return Value From Stored Procedure

Apr 22, 2008

In one of my SSIS jobs I have an 'Execute SQL Task' which is calling a stored procedure. This SP returns 0 or 1, if the SP returns 1 the package needs to stop executing. Is there a way to get the value that is returned from the SP and either continue or stop the job from continuing to run?

so if value is 0 it goes to the next step, if its 1 it stops running

View 8 Replies View Related

Get Return Value From Stored Procedure

Mar 14, 2007

Greetings All,
I am a newbie to SSIS and need some help. I need to get the return value from a stored procedure into a SSIS variable. I'm assuming I would use an OLE DB Command but I havn't a clue on how to capture the return value. Can someone get me started on how I can do this?

Note, the return value is actually an identity of the inserted value. I need this value in my data flow for further processing.

Thanks is advance!

View 6 Replies View Related

How To DataList To Read Stored Procedure Data To A Href Link

Sep 26, 2007

 I am coding a DataList control for 2 column data from a stored procedure.  The 1st column isprogramName and the 2nd is programLink.  I used Edit Template -> Edit DataBonding to add<h ref="http.....>, but can not get it right.  Please help.  Also, what is the Parameter Sourcefor using Logon User ID as a stored procedure paramter when configuring a SqlDataSource? None, cookie, control,..?  TIA,Jeffrey
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" Style="z-index: 16;left: 29px; position: absolute; top: 82px"><ItemTemplate>programName:<asp:Label ID="programNameLabel" runat="server" Text='<%# Eval("programName") %>'></asp:Label><br />programlink:<asp:Label ID="programlinkLabel" runat="server" Text='<%# Eval("programlink") %>'></asp:Label><br /><br /></ItemTemplate></asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:iTemplatesConnectionString %>"SelectCommand="MyPrograms" SelectCommandType="StoredProcedure"><SelectParameters><asp:Parameter Name="meid" Type="Int32" DefaultValue="3532" /></SelectParameters></asp:SqlDataSource>

View 4 Replies View Related

Passing Parameters Read From An Ini File To A Stored Procedure Within DTS Package

Sep 24, 2002

Hi

I was wondering how I could pass on the following parameters from an ini file to a stored procedure within a DTS package. The parameters in the ini file look like:

[DatabaseCleaner]
! -- TableToBeCleaned_N=<table name>,<months to hold on db>,<months to hold on hd>
! -- <N> must be a successive number starting from 1 ...
TableToBeCleaned_1=Transactions,24,24
TableToBeCleaned_2=Payments,24,24
TableToBeCleaned_3=PresenceTickets,24,24

As I do not know how many tables that will be declared in the ini file I have to loop through until the last parameters and pass it over to the SP.

How can I do that? Any idea?

Thanks

mipo

View 1 Replies View Related

SQL Server 2014 :: Using (Try-Catch) And (Rollback) On Read Only Stored Procedure?

Apr 30, 2015

In general as understand if we have a stored procedure that does operations like inserts or updates, it makes perfect sense to use a rollback operation within a transaction.

So, if something goes wrong and the transaction does not complete, all changes will be reverted and an error description will be thrown for example.

Nevertheless, does using a rollback within a try catch statement, make sense in a read only stored procedure, that practically executes some dynamic sql just to select data from some tables?

I have around 100 Stored procedures, all of them read only. Today a colleague suggested adding try-catch blocks with rollback to all of them. But since they are just selecting data, I don't see a clear benefit of doing so, compared to the hassle of changing such a big number of SP's.

View 9 Replies View Related

Return Single Value From Stored Procedure

Jul 10, 2006

   I am have stored procedure that accepts one parameter and returns a single value
The sp works fine.
My question is how do I set the c# webpage to return the single value.
I need a specific example of how to code.
this is how the code should work.
A blank form is loaded, when the user clicks submit I need the code to pull the Login name from the text box and check to see if it exist. I have the sp working the way I need it to. But I can figure how to pull the single value into a variable in the code behind.
I am using dataset elsewhere on the site, so I created a ds the calls the sp. Can it work this way?
thanks,
 

View 3 Replies View Related

Catching A Return From SQL Stored Procedure

Sep 6, 2006

Hi AllHere is my SPALTER PROCEDURE dbo.InsertPagerDays @ReportEndDate datetime, @PagerDays int,@UserID varchar(25)ASIF EXISTS(-- you cannot add a pager days more than once per report dateSELECT ReportEndDate, UserId from ReportPagerDays where ReportEndDate = @ReportEndDate and UserId = @UserID)Return 1 elseSET NOCOUNT OFF;INSERT INTO [ReportPagerDays] ([ReportEndDate], [PagerDays], [UserID]) VALUES (@ReportEndDate, @PagerDays, @UserID)RETURNMy Question is, this SP will not let you enter in a value more than once (which is what i want) but how do I write my code to inform the user? Here is my VB code becuase the SP does not error out (becuase it works it acts as if the record updates)How can I catch the Return 1'set parameters for SPDim cmdcommand = New SqlCommand("InsertPagerDays", conn)cmdcommand.commandtype = CommandType.StoredProcedurecmdcommand.parameters.add("@ReportEndDate", rpEndDate)cmdcommand.parameters.add("@PagerDays", PagerDays)cmdcommand.parameters.add("@UserId", strUserName)Try'open connection hereconn.Open()'Execute stored proccmdcommand.ExecuteNonQuery()Catch ex As Exceptionerrstr = ""'An exception occured during processing.'Print message to log file.errstr = "Exception: " & ex.Messagelblstatus.ForeColor = Drawing.Color.Redlblstatus.Text = "Exception: " & ex.Message'MsgBox(errstr, MsgBoxStyle.Information, "Set User Report Dates")FinallyIf errstr = "" Thenlblstatus.ForeColor = Drawing.Color.Whitelblstatus.Text = "Pager Days Successfully Added!"End If'close the connection immediatelyconn.Close()End Try

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved