I'm focusing on a database application in C#. I'd essential to show data on the table and i'm now completed with that. But my company logic is hardcoded to my code. Now I wish to proceed and employ Saved methods with my code. Do you know the modifications that I have to do. An easy listing of steps could be enough :)

SqlConnection myConnection = new SqlConnection("user id=dbblabla;" + 
			"password=1234;server=localhost\\SQLEXPRESS;" + 
			"Trusted_Connection=yes;" + 
			"database=myDB; " + 
			"connection timeout=30");

try
{
	myConnection.Open();
} catch (SqlException excep){
	Console.WriteLine(excep.StackTrace);
}

String selectionQuery = "SELECT * FROM myTable";
SqlDataAdapter myAdapter = new SqlDataAdapter(selectionQuery,myConnection);

DataSet ds = new DataSet();
myAdapter.Fill(ds,"AllInfo");

dataGridSearchOutput.DataSource = ds.Tables["AllInfo"].DefaultView;

I began from developing a new SQL command but I don't know I'm using the right way.

SqlCommand newCommand = new SqlCommand("SELECT * FROM PMInfo");
newCommand.CommandType = CommandType.StoredProcedure;

Saved-Procedure

CREATE PROCEDURE addemp
     @eno int,
     @ename varchar(50),
     @edate datetime
AS
  declare @p int

  select @p=count(*) from emp
      where eno=@eno
  if @p=0
     begin
       insert into emp
         values (@eno,@ename,@edate)
     end        
    RETURN

C# code

    SqlConnection cn = new SqlConnection(@"conn_str");
    SqlCommand cmd = new SqlCommand("addemp", cn);
    cmd.CommandType = CommandType.StoredProcedure;

    cmd.Parameters.AddWithValue("@eno", 10);
    cmd.Parameters.AddWithValue("@ename", "Mr.Xyz");
    cmd.Parameters.AddWithValue("@edate", DateTime.Parse("1-1-2002"));

    cn.Open();
    cmd.ExecuteNonQuery();
    cn.Close();

saved procedure

CREATE PROCEDURE  procedure 

AS
BEGIN

    SET NOCOUNT ON;
    SELECT field1,field2 from tbl
END
GO

code

using(SqlConnection con = new SqlConnection("user id=dbblabla;password=1234;server=localhost\\SQLEXPRESS; database=myDB; connection timeout=30"))
        {
            SqlCommand cmd = new SqlCommand("procedure",con);
            cmd.CommandType= System.Data.CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            dataGridSearchOutput.DataSource = dt;           

        }

why i made use of using is take a look link

You need to simply specify the saved procedure title towards the SqlCommand constructor and hang the CommandType to CommandType.StoredProcedure. It is also a sensible practice to wrap disposable objects in using block. SqlConnection, SqlCommand and SqlAdapter are disposable objects. This is a modified code.

string connectionString = "user id=dbblabla;" + 
                        "password=1234;server=localhost\\SQLEXPRESS;" + 
                        "Trusted_Connection=yes;" + 
                        "database=myDB; " + 
                        "connection timeout=30";
DataSet ds = new DataSet();
using(SqlConnection myConnection = new SqlConnection(connectionString))
using (SqlCommand command = new SqlCommand("yourprocedure", myConnection))
{
    SqlDataAdapter myAdapter = new SqlDataAdapter();
    myAdapter.SelectCommand = command;
    myAdapter.Fill(ds,"AllInfo");
}
dataGridSearchOutput.DataSource = ds.Tables["AllInfo"].DefaultView;