① 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後的結果讀取問題
直接通過索引讀取