① c# DataSet筛选
加一个条件就行了,出入库情况=‘入’
② DataSet如何应用select语句查询
SqlConnection con = new SqlConnection("server=(local);database=你的数据库名称";uid=sa;pwd=你的数据库密码");
con.Open();
SqlDataAdapter adapter= new SqlCommand(@"select top 1 ID from table where name='" + s + "'order by ID" ,con);
DataSet ds = new DataSet();
adapter.Fill(ds);
这样DataSet中就有数据啦
③ 如何用Dataset 进行条件筛选查询,并显示在DataGradeView中
DataView dv = ds..Tables[0].DefaultView;
dv.RowFilter="select name where="+Textbox1.text;
gradeview.datasource=dv;
④ 用sql语句提取DataSet中表的某个字段
这样不行把。
public
static
dataset
getsql(dataset
pid)
{
string
sql
=
"select
pusername,ppurpose,pphone,pemail
from
[person]
where
";
froeach(datarow
dr
in
pin.table[0].row)
{
sql+="sql="+dr["pid<字段名称>"].tostring();
}
}
这样应该就可以了。
希望对你有帮助。
⑤ 用dataset 怎么筛选读取xml里的数据呢
如XML文件里有个日期字段,我要取出早于当天的数据读到DataSet里:
<?xml version="1.0" standalone="yes"?>
<LocalWork xmlns="http://tempuri.org/Repository.xsd">
<xs:schema id="LocalWork" targetNamespace="http://tempuri.org/Repository.xsd" xmlns:mstns="http://tempuri.org/Repository.xsd" xmlns="http://tempuri.org/Repository.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="LocalWork" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="DailyTable">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:long" />
<xs:element name="日期" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="LocalWorkPKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:DailyTable" />
<xs:field xpath="mstns:ID" />
</xs:unique>
</xs:element>
</xs:schema>
<DailyTable>
<ID>12</ID>
<日期>20051222</日期>
</DailyTable>
<DailyTable>
<ID>14</ID>
<日期>20061222</日期>
</DailyTable>
</LocalWork>
⑥ DataSet保存从DataSet筛选出的内容 万分感谢
dsz =dsz.Tables[0].DefaultView.RowFilter = "客户 = '" + id + "'";
你里面的客户id是整形?
请参阅如下:
CONVERT
说明
将特定表达式转换为指定的 .NET Framework 类型。
语法
Convert(expression, type)
参数
expression — 要转换的表达式。
type — 值将转换成的 .NET Framework 类型。
例如:myDataColumn.Expression="Convert(total, 'System.Int32')"
上面的就可以写成:
dsz =dsz.Tables[0].DefaultView.RowFilter = "客户 = Convert("+id+", 'System.Int32')"
⑦ dataset通过select后的结果读取问题
直接通过索引读取