本文介绍了我写了这段代码,以根据雇主身份获取员工的详细信息。但得到的错误是employeeerid的列名无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  protected   void  Button1_Click(对象发​​件人,EventArgs e)
{
string strConnection = ConfigurationManager.ConnectionStrings [ MyConsString]。ConnectionString;
SqlConnection conn = new SqlConnection(strConnection);
SqlCommand cmd = new SqlCommand( 选择*来自Employeertable INNER JOIN Employeetable Employeertable.Employeerid = Employeetable.Employeerid,其中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();

}
}
解决方案

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();

    }
}
解决方案


这篇关于我写了这段代码,以根据雇主身份获取员工的详细信息。但得到的错误是employeeerid的列名无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 05:21