Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to .NET . I have created an table.Now i want to display the details of a table that i have inserted into it.Please provide a simple code so that i can easily under stand
Posted

 
Share this answer
 
//this is the stored procedure:
ALTER PROCEDURE [dbo].[LogInProcedure]
	@username nvarchar (50),
	@password nvarchar (50),
	@groupnum nvarchar (50)
AS
	SET NOCOUNT ON;
SELECT	* FROM users 
WHERE	user_username=@username AND user_password=@password

//this is the code for retrieving info from it:
public bool doLogIn(string username, string password)
        {
            con.Open();

            SqlCommand cmd = new SqlCommand("LogInProcedure", con);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@username", username);
            cmd.Parameters.AddWithValue("@password", password);

            SqlDataReader read = cmd.ExecuteReader();

            if (read.HasRows)
                return true;
            else
                return false;
        }
 
Share this answer
 
Comments
vinod.sambangi 19-Nov-12 8:33am    
I think you might have said by using layering concept.But i want to display the details while the page was loading itself.So please tell me what to write while the page was loading to display the table data in a asp.net page
[no name] 19-Nov-12 8:41am    
Call this function on Page_Load event.
vinod.sambangi 20-Nov-12 3:21am    
Which function??i could call
[no name] 20-Nov-12 6:27am    
public bool doLogIn(string username, string password)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900