我用一下程序:
private void tongji1_Click(object sender, System.EventArgs e)
{
DataGridBind();
}
public void DataGridBind()
{
string strsql = "select users_id,username,hometown,mobilephone,dep_name from users,dep where users.dep_id=dep.dep_id";
if(dep_name.selectvalue!="")
{
str+="and dep.dep_name=" + this.dep_name.SelectedValue.ToString().Trim() + ""; }
conn.Open();
da = new SqlDataAdapter(strsql,conn);
ds = new DataSet();
da.Fill(ds,"TongjiDep"); //出错
DataView dv = ds.Tables[0].DefaultView;
DataGrid1.DataSource = dv;
DataGrid1.DataBind();
conn.Close();
}
会出现错误
将varchar值"人事部"转换为数据类型为int的列时发生语法错误?
这是怎么回事啊??