- 关 键 词:
- visual basic
- jscript
- c++
Gets a specified DataRow.
Overload List
Gets the row specified by the primary key value.
[Visual Basic] Overloads Public Function Find(Object) As DataRow
[C#] public DataRow Find(object);
[C++] public: DataRow* Find(Object*);
[JScript] public function Find(Object) : DataRow;
Gets the row containing the specified primary key values.
[Visual Basic] Overloads Public Function Find(Object()) As DataRow
[C#] public DataRow Find(object[]);
[C++] public: DataRow* Find(Object*[]);
[JScript] public function Find(Object[]) : DataRow;
Example
[Visual Basic, C#] The following example uses the values of an array to find a specific row in a collection of DataRow objects. The method presumes a DataTable exists with three primary key columns. After creating an array of the values, the code uses the Find method with the array to get the particular object desired.
[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of Find. For other examples that might be available, see the individual overload topics.
[Visual Basic]
Private Sub FindInMultiPKey(ByVal myTable As DataTable)
Dim foundRow As DataRow
' Create an array for the key values to find.
Dim findTheseVals(2) As Object
' Set the values of the keys to find.
findTheseVals(0) = "John"
findTheseVals(1) = "Smith"
findTheseVals(2) = "5 Main St."
foundRow = myTable.Rows.Find(findTheseVals)
' Display column 1 of the found row.
If Not (foundRow Is Nothing) Then
Console.WriteLine(foundRow(1).ToString())
End If
End Sub
[C#]
private void FindInMultiPKey(DataTable myTable){
DataRow foundRow;
// Create an array for the key values to find.
object[]findTheseVals = new object[3];
// Set the values of the keys to find.
findTheseVals[0] = "John";
findTheseVals[1] = "Smith";
findTheseVals[2] = "5 Main St.";
foundRow = myTable.Rows.Find(findTheseVals);
// Display column 1 of the found row.
if(foundRow != null)
Console.WriteLine(foundRow[1]);
}
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button in the upper-left corner of the page.文字:http://www.qqread.com/dotnet/s236010.html进入讨论组讨论。
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
相关专题
- VB.NET 入门教程 (22167次浏览)
- asp.net 实现购物车详细代码 (14312次浏览)
- C#版的网站新闻发布系统 (690次浏览)
- ASP.NET2.0轻松搞定统计图表 (651次浏览)
- 使用ASP.NET AJAX实现幻灯片效果 (604次浏览)
- ASP.NET如何存取 SQLServer数据库图片 (592次浏览)
- 如何制作Asp.Net界面模板 (582次浏览)
- ASP.NET中实现DataGrid数据排序 (580次浏览)
- VB.NET读写文本文件方法 (579次浏览)
- VC#初学入门:第一个Windows程序 (536次浏览)



