Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to send consecutive stored procedures and its parameters

Reply
Thread Tools

How to send consecutive stored procedures and its parameters

 
 
Sharon
Guest
Posts: n/a
 
      02-03-2010
Hi Community

I have an ASP.NET web project. In this project I am consecutively
sending and passing 5 different stored procedures along with a parameter to
a receiving method. The first stored procedure (sp1) and its parameter gets
processed by the receiving method without a problem but when the second
stored procedure (sp2) gets passed with its parameter to the receiving method
the receiving method crashes and the program aborts. Below is an example of
how I am trying to pass the 5 stored procedures along with its parameter to
the receiving method,
the lines that it seems to crash on are marked:

***below is the are the stored procedures getting passed consecutively

Public DataSet getDS()
{
CreateCmd ("sp1", @Params, ref ds);
CreateCmd ("sp2", @Params, ref ds);
CreateCmd ("sp3", @Params, ref ds);
CreateCmd ("sp4", @Params, ref ds);
CreateCmd ("sp5", @Params, ref ds);
}


***below is the method that receives and processes the stored procedures
sent above

private SqlCommand CreateCmd(string strSql, SqlParameter[] Param,
CommandType SQLCmdType)
{
Conn = new SqlConnection(GetConn ());
SqlCommand Createcmd = new SqlCommand(strSql, Conn);


Createcmd.CommandType = SQLCmdType;

if (Param != null) <<< crash
{
foreach (SqlParameter p1 in Param) ) <<< crash

{
Createcmd.Parameters.Add(p1); ) <<< crash

}
}
Conn.Open();
return Createcmd;

}

My question is how can I pass consecutive stored procedurs with their
parameters to another method to be processed?



 
Reply With Quote
 
 
 
 
Mr. Arnold
Guest
Posts: n/a
 
      02-04-2010
Sharon wrote:
> Hi Community
>
> I have an ASP.NET web project. In this project I am consecutively
> sending and passing 5 different stored procedures along with a parameter to
> a receiving method. The first stored procedure (sp1) and its parameter gets
> processed by the receiving method without a problem but when the second
> stored procedure (sp2) gets passed with its parameter to the receiving method
> the receiving method crashes and the program aborts. Below is an example of
> how I am trying to pass the 5 stored procedures along with its parameter to
> the receiving method,
> the lines that it seems to crash on are marked:
>


So why can't you use one SP1, pass its parms, and all the other parms to
all the SP(s) to SP1. Then SP1 does its resultset and calls the other
SP(s)to produce their resultsets, a multiple results resultset?

Then you use a SQL DataReader read the first resultset, get the
infromation, do reader.nextresult read the data, etc, etc.
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      02-04-2010
On Feb 4, 12:29*am, Sharon <(E-Mail Removed)> wrote:
> Hi Community
>
> * * I have an ASP.NET web project. *In this project I am consecutively
> sending and *passing 5 different stored procedures along with a parameter to
> a receiving method. *The first stored procedure (sp1) *and its parameter gets
> processed by the receiving method without a problem but when the second
> stored procedure (sp2) gets passed with its parameter to the receiving method
> the receiving method crashes and the program aborts. Below is an example of
> how I am trying to pass the 5 stored procedures along with its parameter to
> the receiving method,
> the lines that it seems to crash on are marked:
>
> ***below is the are the stored procedures getting passed consecutively
>
> Public DataSet getDS()
> {
> * * CreateCmd ("sp1", @Params, ref ds);
> * * CreateCmd ("sp2", @Params, ref ds);
> * * CreateCmd ("sp3", @Params, ref ds);
> * * CreateCmd ("sp4", @Params, ref ds);
> * * CreateCmd ("sp5", @Params, ref ds);
>
> }
>
> ***below is the method that receives and processes the stored procedures
> sent above
>
> * * * *private SqlCommand CreateCmd(string strSql, SqlParameter[] Param,
> CommandType SQLCmdType)
> * * * * {
> * * * * * * Conn = new SqlConnection(GetConn ());
> * * * * * * SqlCommand Createcmd = new SqlCommand(strSql, Conn);
>
> * * * * * * Createcmd.CommandType = SQLCmdType;
>
> * * * * * * if (Param != null) * * * * * * * * * * * * *<<< crash
> * * * * * * {
> * * * * * * * * foreach (SqlParameter p1 in Param) ) * *<<< crash
>
> * * * * * * * * {
> * * * * * * * * * * Createcmd.Parameters.Add(p1); ) * * <<< crash
>
> * * * * * * * * }
> * * * * * * }
> * * * * * * Conn.Open();
> * * * * * * return Createcmd;
>
> * * * * }
>
> My question is how can I pass consecutive stored procedurs with their
> parameters to another method to be processed?


I don't get what does "@Params" mean when you call CreateCmd()? You
need to pass an array of SqlParameter[]

CreateCmd ("sp1", @Params, ref ds);

And why "ref ds" is used? I think you don't need to refer to the same
variable there. Get rid of ref.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Its a bird, its a plane, no ummm, its a Ruide thunk Ruby 1 03-30-2010 11:10 AM
adodbapi and output parameters in stored procedures leesquare@yahoo.com Python 4 11-08-2008 02:25 PM
ruby odbc and binding OUT parameters in stored procedures Chris Hall Ruby 0 11-15-2006 04:41 PM
ASp.net stored procedures parameters for search functions .Net Sports ASP .Net 3 05-11-2005 11:43 PM



Advertisments