shoaib shamsuddin

shoaib shamsuddin

  • 1.8k
  • 386
  • 11.8k

SelecIndex Change With Store Proc

Jun 25 2022 6:26 AM

USE [EmployeeDB]
GO
/****** Object:  StoredProcedure [dbo].[spFetchWorkerDetails]    Script Date: 6/25/2022 11:06:02 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spFetchWorkerDetails]@WorkerID int
AS
BEGINSET NOCOUNT ON;select *from Memberwhere WorkerID =@WorkerIDEND

 

USE [EmployeeDB]
GO
/****** Object:  StoredProcedure [dbo].[SpGetWorkerNameList]    Script Date: 6/25/2022 11:26:06 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SpGetWorkerNameList]
AS
BEGINSET NOCOUNT ON;
select -1 AS WorkerID, 'Select WorkName' as FirstName union
Select WorkerID,FirstName From Member ORDER BY  WorkerID DESC , FirstName ; 
END

this Query Get Name List 

 

private void DllName_SelectedIndexChanged(object sender, EventArgs e)
        {
            string EmpID = "";

            SqlConnection connection = new SqlConnection(myconn);
            SqlCommand cmd = new SqlCommand("spFetchWorkerDetails", connection);
            cmd.Parameters.AddWithValue("@WorkerID", EmpID);
            connection.Open();
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            SqlDataReader dataReader = cmd.ExecuteReader();
            while (dataReader.Read())
            {
                //txtboxID.Text = (dataReader["WorkerID"].ToString());
                txtName.Text = (dataReader["FirstName"].ToString());
                ComboxDesignation.Text = (dataReader["Designation"].ToString());
                txtOccupation.Text = (dataReader["Occupation"].ToString());
                txtCnic.Text = (dataReader["Cnic"].ToString());
                txtWorkWith.Text = (dataReader["WorkWith"].ToString());

            }
            connection.Close();

        }

 


Answers (9)