Populate 3 combobox from same table but use filter in all 3 tables

i have a windows application having 3 combobox. username, prepared by, authorized by. i want name of all employees in user name whereas in prepared by and authorized by i want selected names but from the same table. so i have assigned roles in the employee table which is an integer value and fired a stroed procedure. i cannot populate the combobox

SQL:

emp table:
create table emp1
(
    employee_id int constraint pk_employee_id_employee primary key not null,
    un_id varchar(10) constraint uk_un_id_employee unique not null,
    fname varchar(20) not null,
    lname varchar(20) not null,
    roles int not null
)

stored procedure:
alter proc rolecombo
(
    @roles int  
)
as begin
select * from emp1 where roles<@roles
end

C# code:

 private void Form1_Load(object sender, EventArgs e)
        {
            con.Open();
            adp = new SqlDataAdapter(cmd);
            cmd.Connection = con;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "rolecombo";
            cmd.Parameters.AddWithValue("@roles",comboBox3.SelectedValue);
            adp.Fill(dsautho, "emp1");
            comboBox3.DataSource = dsautho.Tables["emp1"];
            comboBox3.DisplayMember = "fname";
            comboBox3.ValueMember = "employee_id";
            comboBox3.SelectedIndex = -1;
            con.Close();
}

Answers


Try this Sample Code:

public static DataSet DownDataBind()
{
    try
    {
        SqlConnection conn = new SqlConnection("Data Source=S1B01689;Initial Catalog=CosmosDB;User Id=sa;Password=Nttdata123");
        conn.Open();

        SqlDataAdapter adapter = new SqlDataAdapter("SELECT id,categName from CM_Categories",conn);
        DataSet ds = new DataSet();

        adapter.Fill(ds);

        adapter.Dispose();

        conn.Close();

        return ds;
    }
    catch (Exception exp)
    {
        string s = exp.Message.ToString();
        return null;
    }
}

private void Form1_Load(object sender, EventArgs e)
{
    try
    {
        DataSet ds = DownDataBind();
        comboBox1.DataSource = ds.Tables[0];// use Tables[0] instead of Table Name
        comboBox1.ValueMember = "Id";
        comboBox1.DisplayMember = "CategName";
        comboBox1.SelectedIndex = -1;         
    }
    catch (Exception exp)
    {
        MessageBox.Show(exp.Message);
    }
}

Need Your Help

Parsing url params in expressjs - angularjs application

node.js angularjs express routing

Struck with routing issue in expressjs and AngularJs project.

In tsql what does tablename(1) mean

sql tsql

I'm trying to analyze a query to extract the logic and I am seeing several select statements that use the syntax SELECT FROM tableName(1). Below is a few examples of this syntax being used. This is a

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.