CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> .NET

 Execute Stored Procedure using ASP.NET 2.0

Print topic Send  topic

Author Message
akhan


Posts: 38
Posted: 07/02/2007, 2:24 AM

Hi There,

I have successfully used the following code in asp.net version 1.1. However its is not working when using a asp.net 2.0 project

  
Dim sessionStart=new SpCommand("USP_sessionUpdate" ,Settings.BTSDataAccessObject)  
  
sessionStart.Parameters.Clear()  
  
CType(sessionStart,SpCommand).AddParameter("@sessionID",sessionID,ParameterType._Char,ParameterDirection.Input,50,0,10)  
  
sessionStart.ExecuteNonQuery   


Can anyone help me with this please.


Thanks,


Abs
_________________
"Simplicity is the key to brilliance” (bruce lee)
View profile  Send private message
chavakoti

Posts: 3
Posted: 07/03/2007, 9:28 PM

con = new SqlConnection(ConfigurationManager.ConnectionStrings["sstr"].ConnectionString);
cmd = new SqlCommand("USP_STU", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@s_no", SqlDbType.Int, 9);
cmd.Parameters["@s_no"].Direction = ParameterDirection.Input;

cmd.Parameters["@s_no"].Value = 1;
cmd.Parameters.Add("@s_marks", SqlDbType.Int);
cmd.Parameters["@s_marks"].Direction = ParameterDirection.Output;
con.Open();
cmd.ExecuteNonQuery();
int marks = (int)cmd.Parameters["@s_marks"].Value;
Response.Write(marks);
con.Close();



===========================
con = new SqlConnection(ConfigurationManager.ConnectionStrings["sstr"].ConnectionString);
cmd = new SqlCommand("USP_STU", con);
cmd.CommandType = CommandType.StoredProcedure;
ad = new SqlDataAdapter(cmd);
ds = new DataSet();
ad.Fill(ds);
GV1.DataSource = ds;
GV1.DataBind();

<PRE lang=cs id=pre2 style="MARGIN-TOP: 0px" nd="59">private void BindData()
{
string connectionString = "Server=localhost;" +
"Database=Northwind;Trusted_Connection=true";
SqlConnection myConnection = new SqlConnection(connectionString);
SqlCommand myCommand = new SqlCommand("usp_GetProducts",
myConnection);
myCommand.CommandType = CommandType.StoredProcedure;

myCommand.Parameters.AddWithValue("@startRowIndex",
currentPageNumber);
myCommand.Parameters.AddWithValue("@maximumRows", PAGE_SIZE);
myCommand.Parameters.Add("@totalRows", SqlDbType.Int, 4);
myCommand.Parameters["@totalRows"].Direction =
ParameterDirection.Output;

SqlDataAdapter ad = new SqlDataAdapter(myCommand);

DataSet ds = new DataSet();
ad.Fill(ds);

gvProducts.DataSource = ds;
gvProducts.DataBind();

// get the total rows
double totalRows = (int)myCommand.Parameters["@totalRows"].Value;

lblTotalPages.Text = CalculateTotalPages(totalRows).ToString();

lblCurrentPage.Text = currentPageNumber.ToString();

if (currentPageNumber == 1)
{
Btn_Previous.Enabled = false;

if (Int32.Parse(lblTotalPages.Text) > 0)
{
Btn_Next.Enabled = true;
}
else
Btn_Next.Enabled = false;

}

else
{
Btn_Previous.Enabled = true;

if (currentPageNumber == Int32.Parse(lblTotalPages.Text))
Btn_Next.Enabled = false;
else Btn_Next.Enabled = true;
}
}</PRE>



++++++++++++++++++++++++++++++++++

<PRE lang=sql nd="11">CREATE PROCEDURE [usp_GetProducts]
@startRowIndex int,
@maximumRows int,
@totalRows int OUTPUT

AS

DECLARE @first_id int, @startRow int

SET @startRowIndex = (@startRowIndex - 1) * @maximumRows

IF @startRowIndex = 0
SET @startRowIndex = 1

SET ROWCOUNT @startRowIndex

SELECT @first_id = ProductID FROM Products ORDER BY ProductID

PRINT @first_id

SET ROWCOUNT @maximumRows

SELECT ProductID, ProductName FROM Products WHERE
ProductID >= @first_id
ORDER BY ProductID

SET ROWCOUNT 0

-- GEt the total rows

SELECT @totalRows = COUNT(ProductID) FROM Products
GO</PRE>


_________________
From Hyderabad,Yash Technologies
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.