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) |
|
|
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 |
|
|
|