Subscribe to Subscribers
Talk to Webmaster Tony John

Online Members

baskar
More...


Forums » .NET » ASP.NET »

How catch results of stored procedure in asp.net page


Posted Date: 29 Jun 2012      Posted By:: chinnari     Member Level: Silver    Member Rank: 1592     Points: 3   Responses: 1



i am connecting to oracle database function through my asp.net page. My database function is returning 4 cursors and i want to load 4 cursors in 4 different datatables in asp.net page. How to do that? How to catch result of my database function in my page and how to load those into datatable or dataset?
Please help me.




Responses

#678191    Author: Lalji      Member Level: Gold      Member Rank: 131     Date: 30/Jun/2012   Rating: 2 out of 52 out of 5     Points: 4

First you have to Create a Storedprocure that counts the Records that match the username and password,

Create Procedure prclogin_check
(
@User_name varchar(20),
@U_Password varchar(23),
@Results int Output
)
Set @Results = (Select count(*) from User_Table
where User_name =@User_name and U_Password = @U_Password)


And after you are done with this , you have to do the Following in your C# Code

using System.Data.SqlClient;
String strcon = "User id = sa;Password= topman;Server=myServer;Database=MyDB";
SqlConnection con = new SqlConnection(strcon);
SqlCommand cmdselect = new SqlCommand();
cmdselect.CommandTimeout = 0;
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.Connection = con;
cmdselect.CommandText = "prclogin_check";
cmdselect.Parameters.Add("@Results",SqlDbType.Int,4);
cmdselect.Parameters["@Results"].Direction = ParameterDirection.Output;
int Res;
try
{
con.Open();
cmdselect.ExecuteNonQuery();
Res = (int)cmdselect.Parameters["@Results"].Value;
con.Close();
}
catch (SqlException e)
{
MessageBox.Show(e.Message);
}



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Specified argument was out of range
Previous : How to form query dynamically for linq
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.