Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
C#
protected void Button1_Click(object sender, EventArgs e)
    {
        string strConnection = ConfigurationManager.ConnectionStrings["MyConsString"].ConnectionString;
        SqlConnection conn = new SqlConnection(strConnection);
        SqlCommand cmd = new SqlCommand("Select * from Employeertable INNER JOIN Employeetable on Employeertable.Employeerid= Employeetable.Employeerid where Employeertable.Employeerid=" + DropDownList1.SelectedItem.ToString() + "", conn);
        conn.Open();
        cmd.ExecuteNonQuery();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
        conn.Close();

    }
}
Posted
Updated 3-Jan-13 20:27pm
v3

1 solution

its a string so we need to include single quotation
 
Share this answer
 
v2

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