tags:

views:

154

answers:

3

hello

In asp.net(C#) i want fetch data from the database using stored procedure and display them in controls... for exmp... "Name" in textbox1

"contact" num in textbox2 any help as i new with this

thanks

A: 

If you are using 3.5 sp1, then I suggest you try the entity framework. You can map a stored procedure over and it will behave in code just like any other C# function (in a very broad sense).

tutorial here: http://msdn.microsoft.com/en-us/library/bb386876.aspx

Russell Steen
sorry boss i didnt get this ...can u gve any other way...inserting,update and deltetion i have done bt i want 2 display record in control for which i have searched...and want to show....thanks
Neerav Chauhan
welll thankx mark for the ideathnkx again
Neerav Chauhan
A: 

Stored Procedure:

USE [MyDB]
GO
/******Object: StoredProcedure [dbo].[GetNameByID] Script Date: 11/03/2009 07:10:10******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[GetNameByID] 
-- Add the parameters for the stored procedure here
@NameID int
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    SELECT dbo.Names.Name
    FROM dbo.MyDB
    WHERE dbo.Names.NameID=@NameID
END

DALC Class:

public static string GetNameByID(int nameID)
        {
            SqlParameter[] parameters = new SqlParameter[1];

            parameters[0] = new SqlParameter("@NameID", 
                System.Data.SqlDbType.Int, 8, "nameID");
                    parameters[0].Value = nameID;

            try
            {
                return (SqlHelper.ExecuteNonQuery(dbConnection, 
                    CommandType.StoredProcedure,
                        "GetNameByID", parameters));
            }
            catch
            {
                throw;
            }
            finally
            {
                dbConnection.Close();
            }
        }
IrishChieftain
+1  A: 

Check out some of those beginner's video series (some topics would be intermediate to advanced - find those of interest to you):

Marc

marc_s