I want to get the row count.
I am doing the following to see are there any records in the dataset with the same ID, But i am in the edit mode, obviously there will be one so i want to check are there two rows with same strAccessID.
Please help how i can get the count after doing the find.
Thank you very much.
<code>
Dim Row As DataRow
myDataSet.Tables(0).PrimaryKey = New DataColumn() {myDataSet.Tables(0).Columns("AccessID")}
Row = myDataSet.Tables(0).Rows.Find(CInt(strAccessID))
If Not Row Is Nothing Then
SimpleMessageBox("You cannot have more than one record with same ID.")
Exit Sub
End If
</code>
If the data to the dataset is comming from the database you can checkthat "Duplicate" data is never entered in the first place.
Its a C# code but u can see the concept and can see its alternate in VB.NET
If u want to retreive the coutn of rows in the dataset then u can use
dset.Tables[0].Rows.Count
dset is ur dataset this will give u the count of rows that are in dataset.And u can loop less thandset.Tables[0].Rows.Countand chechk that whether the key already exists or not.
It will work,Feel free to ask more...
How can i check a specific column only in the datasets data this column is a unique column so i dont want to have no two records in the datasets data with the same straccessid, if there are any records with this value strAccessID.
dset.Tables[0].Rows.Count
Another thing i use the dataset on the front end with the xml file means each time i fill the data in the dataset is not from the Database, only the first time i get the data from database and fill to dataset and also write the data to xml file now, i play with the data on the front end in the disconnected mode. and finally when everything is done then i upload all my xml files data using sqlxmlbulkload to database table.
Please let me know, Thank you very much.
0 comments:
Post a Comment