c#将查询到SQL的数据放到DataTable里,再根据条件查询放到新的表里
程序员文章站
2022-07-12 13:59:47
...
//获取问题类型
public void getQuestion_type()
{
SqlConnection conntype = new SqlConnection(ClassConnAll.conmmsy); //实例化SQLconnection类。连接数据库
DataSet Dstype = new DataSet();
//string Sqltype = "select (ltrim(rtrim(staffid))+'['+ ltrim(rtrim(StaffName))+']') as item_clsno from Hion_AgentInfo";
string Sqltype = "select * from codeAll";
SqlDataAdapter Datype = new SqlDataAdapter(Sqltype, conntype);
Datype.Fill(Dstype); // Da.Fill(Ds, "t_bd_branch_info");
DataTable dtAllCode = new DataTable();
dtAllCode = Dstype.Tables[0];
conntype.Close();
//dtAllCode的数据,根据字段codeType='01'时,读取数据出来,方且放到新的c 里
dtAllCode.DefaultView.RowFilter = "codeType='01'";
DataTable c = dtAllCode.DefaultView.ToTable();
}
https://blog.csdn.net/xiongyongting/article/details/53636869