Showing posts with label dataset. Show all posts
Showing posts with label dataset. Show all posts

Saturday, March 24, 2012

Please help how to get the count of rows in Datasets data

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>

DataTable.Rows.Find will only find a specific row in a collection of DataRow objects, so you may need to useDataTable.Select Method.


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.

Wednesday, March 21, 2012

Please Help me- Returning DataSet from a Web Service

Hi All
My Web Service is returning a DataSet. I realized that we cannot
return a DataReader.. Normally we can use a DataReader( when not
using Web services) and access it as below to assign values of columns
of returned rows to Labels in the client aplication such as:
while (dtrJobDetails.Read())
{
l_shortjobdesc.Text = dtrJobDetails["shortjobdesc"].ToString();
}
where dtrJobDetails is a DataReader.
But now I am forced to return back a DataSet.. Is there anyway of
showing the individual column values returned from a DataSet in
individual labels like we do in a DataReader as above... I dont want
to show it in a DataGrid or a DataList...
Please help me.. I have been trying to figure this out since two
days..
Any help will be highly appreciated...
Thanks,
SumairaHi, you could try something like
DataSet oDS = ' Retrieved from your webservice'
Response.Write(oDS.Tables[0].DefaultView[0].Row["Blah"].ToString());
hth
Mark
"Sumaira Ahmad" <sumaira.ahmad@.gmail.com> wrote in message
news:1627c5ae.0411011325.75864c65@.posting.google.com...
> Hi All
> My Web Service is returning a DataSet. I realized that we cannot
> return a DataReader.. Normally we can use a DataReader( when not
> using Web services) and access it as below to assign values of columns
> of returned rows to Labels in the client aplication such as:
> while (dtrJobDetails.Read())
> {
> l_shortjobdesc.Text = dtrJobDetails["shortjobdesc"].ToString();
> }
> where dtrJobDetails is a DataReader.
> But now I am forced to return back a DataSet.. Is there anyway of
> showing the individual column values returned from a DataSet in
> individual labels like we do in a DataReader as above... I dont want
> to show it in a DataGrid or a DataList...
> Please help me.. I have been trying to figure this out since two
> days..
> Any help will be highly appreciated...
> Thanks,
> Sumaira
foreach (DataRow dr in ds.Tables[0])
{
l_shortjobdesc.Text = dr["shortjobdesc"].ToString();
}
note: you should avoid databinding with DataReaders as it may cause
blocking/scaling/resource problems, because databinding is slow, and occurs
after the query. passing datasets is a much better solution. it adds very
little overhead, but frees the query pipe quickly, releasing the locks.
-- bruce (sqlwork.com)
"Sumaira Ahmad" <sumaira.ahmad@.gmail.com> wrote in message
news:1627c5ae.0411011325.75864c65@.posting.google.com...
> Hi All
> My Web Service is returning a DataSet. I realized that we cannot
> return a DataReader.. Normally we can use a DataReader( when not
> using Web services) and access it as below to assign values of columns
> of returned rows to Labels in the client aplication such as:
> while (dtrJobDetails.Read())
> {
> l_shortjobdesc.Text = dtrJobDetails["shortjobdesc"].ToString();
> }
> where dtrJobDetails is a DataReader.
> But now I am forced to return back a DataSet.. Is there anyway of
> showing the individual column values returned from a DataSet in
> individual labels like we do in a DataReader as above... I dont want
> to show it in a DataGrid or a DataList...
> Please help me.. I have been trying to figure this out since two
> days..
> Any help will be highly appreciated...
> Thanks,
> Sumaira

Please Help me- Returning DataSet from a Web Service

Hi All

My Web Service is returning a DataSet. I realized that we cannot
return a DataReader.. Normally we can use a DataReader( when not
using Web services) and access it as below to assign values of columns
of returned rows to Labels in the client aplication such as:

while (dtrJobDetails.Read())
{
l_shortjobdesc.Text = dtrJobDetails["shortjobdesc"].ToString();
}
where dtrJobDetails is a DataReader.

But now I am forced to return back a DataSet.. Is there anyway of
showing the individual column values returned from a DataSet in
individual labels like we do in a DataReader as above... I dont want
to show it in a DataGrid or a DataList...

Please help me.. I have been trying to figure this out since two
days..

Any help will be highly appreciated...
Thanks,
SumairaHi, you could try something like

DataSet oDS = ' Retrieved from your webservice'
Response.Write(oDS.Tables[0].DefaultView[0].Row["Blah"].ToString());

hth
Mark

"Sumaira Ahmad" <sumaira.ahmad@.gmail.com> wrote in message
news:1627c5ae.0411011325.75864c65@.posting.google.c om...
> Hi All
> My Web Service is returning a DataSet. I realized that we cannot
> return a DataReader.. Normally we can use a DataReader( when not
> using Web services) and access it as below to assign values of columns
> of returned rows to Labels in the client aplication such as:
> while (dtrJobDetails.Read())
> {
> l_shortjobdesc.Text = dtrJobDetails["shortjobdesc"].ToString();
> }
> where dtrJobDetails is a DataReader.
> But now I am forced to return back a DataSet.. Is there anyway of
> showing the individual column values returned from a DataSet in
> individual labels like we do in a DataReader as above... I dont want
> to show it in a DataGrid or a DataList...
> Please help me.. I have been trying to figure this out since two
> days..
> Any help will be highly appreciated...
> Thanks,
> Sumaira
foreach (DataRow dr in ds.Tables[0])
{
l_shortjobdesc.Text = dr["shortjobdesc"].ToString();
}

note: you should avoid databinding with DataReaders as it may cause
blocking/scaling/resource problems, because databinding is slow, and occurs
after the query. passing datasets is a much better solution. it adds very
little overhead, but frees the query pipe quickly, releasing the locks.

-- bruce (sqlwork.com)

"Sumaira Ahmad" <sumaira.ahmad@.gmail.com> wrote in message
news:1627c5ae.0411011325.75864c65@.posting.google.c om...
> Hi All
> My Web Service is returning a DataSet. I realized that we cannot
> return a DataReader.. Normally we can use a DataReader( when not
> using Web services) and access it as below to assign values of columns
> of returned rows to Labels in the client aplication such as:
> while (dtrJobDetails.Read())
> {
> l_shortjobdesc.Text = dtrJobDetails["shortjobdesc"].ToString();
> }
> where dtrJobDetails is a DataReader.
> But now I am forced to return back a DataSet.. Is there anyway of
> showing the individual column values returned from a DataSet in
> individual labels like we do in a DataReader as above... I dont want
> to show it in a DataGrid or a DataList...
> Please help me.. I have been trying to figure this out since two
> days..
> Any help will be highly appreciated...
> Thanks,
> Sumaira