如果我用如下语句 创建一个datatable:employee
...
myDataAdapter.Fill(myDS,“employee”);
...
怎么来使用这个employee呢?例如查询之类的
有没有select * from datatable.employee 之类的?
...
myDataAdapter.Fill(myDS,“employee”);
...
怎么来使用这个employee呢?例如查询之类的
有没有select * from datatable.employee 之类的?
解决方案 »
- 网站前台和后台应该怎样分工跟合作,怎样分开工作
- 带分隔符的string 类型数据 如何分割插入listbox?
- 页面与用户控件传参
- 右键点击单元格,如何知道点击的是哪个单元格?
- e.Row.RowState 即是Alternate又是Edit,我判断的时候怎么写???e.Row.RowState == DataControlRowState.Edit只能一个
- 请指教,谢谢。
- 关于treeview控件的显示问题
- 刚刚接触C#,有些问题麻烦一下
- 这行代码怎样理解?
- 哪位高手能帮我解决这三个问题!!!!
- 请问:<!--include-->与Server.Execute()的区别???
- 谁用过datagrid 下面的 updatacommand事件啊?微软给的例子有问题。。
得出来的是employee表字段ID和pId相同的所有记录
获取 DataRow 对象的数组。
private static void GetRowsByFilter()
{
DataTable customerTable = new DataTable( "Customers" );
// Add columns
customerTable.Columns.Add( "id", typeof(int) );
customerTable.Columns.Add( "name", typeof(string) ); // Set PrimaryKey
customerTable.Columns[ "id" ].Unique = true;
customerTable.PrimaryKey = new DataColumn[] { customerTable.Columns["id"] }; // Add ten rows
for( int id=1; id<=10; id++ )
{
customerTable.Rows.Add(
new object[] { id, string.Format("customer{0}", id) } );
}
customerTable.AcceptChanges(); // Add another ten rows
for( int id=11; id<=20; id++ )
{
customerTable.Rows.Add(
new object[] { id, string.Format("customer{0}", id) } );
} string strExpr;
string strSort;
strExpr = "id > 5";
// Sort descending by column named CompanyName.
strSort = "name DESC";
// Use the Select method to find all rows matching the filter.
DataRow[] foundRows =
customerTable.Select( strExpr, strSort, DataViewRowState.Added );
PrintRows( foundRows, "filtered rows" ); foundRows = customerTable.Select();
PrintRows( foundRows, "all rows" );
}private static void PrintRows( DataRow[] rows, string label )
{
Console.WriteLine( "\n{0}", label );
if( rows.Length <= 0 )
{
Console.WriteLine( "no rows found" );
return;
}
foreach( DataRow r in rows )
{
foreach( DataColumn c in r.Table.Columns )
{
Console.Write( "\t {0}", r[c] );
}
Console.WriteLine();
}
}