Re: Bindingsource Find method
- From: "Ilya Tumanov [MS]" <ilyatum@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 22 Jun 2006 12:39:28 -0700
RS does not have any data inside, so you can not use Find(), IndexOf() and
so on - there's no data to find or compare against.
The idea of RS is what if you need to find something, SQL Mobile should do
that. So please construct another SQL query and execute new RS.
If that does not fit your pattern, please use DataSet which loads all the
data to allow for Find().
--
Best regards,
Ilya
This posting is provided "AS IS" with no warranties, and confers no rights.
*** Want to find answers instantly? Here's how... ***
1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
"Mark Huisinga" <mhuisinga@xxxxxxxxxxxxxxxxx> wrote in message
news:nJvmg.33352$UQ2.4279@xxxxxxxx
categoriesResultSet is generated.(Northwind).
categoriesResulstSet set to Detail in the Data Sources then dragged onto a
form.
call Addnew, Then type exisiting CategoryID in Category ID Text Box. Now I
want to retrieve the corresponding record and position the BindingSource
on the corresponding record.
private void Form1_Load(object sender, EventArgs e)
{
categoriesResultSet = new
DeviceApplication3.CategoriesResultsetResultSets.CategoriesResultSet();
categoriesResultSet.Bind(this.categoriesResultSetBindingSource);
}
private void btnAddnew_Click(object sender, EventArgs e)
{
categoriesResultSetBindingSource.AddNew();
}
private void category_IDTextBox_LostFocus(object sender, EventArgs e)
{
// solution 1
if (categoriesResultSetBindingSource.SupportsSearching == false)
{
// too bad, this whould have made life easy
MessageBox.Show("No search support");
}
// solution 2
// try seek but doesn't work
if
(categoriesResultSet.Seek(System.Data.SqlServerCe.DbSeekOptions.FirstEqual,
new object[] { category_IDTextBox.Text }))
{
categoriesResultSet.Read();
categoriesResultSetBindingSource.DataSource =
categoriesResultSet.ResultSetView;
}
// solution 3
// this also doesn't work. Presumably pass the record as parameter, but
how to get record ?
int index =
categoriesResultSetBindingSource.IndexOf(category_IDTextBox.Text);
if (index > 0)
{
categoriesResultSetBindingSource.Position = index;
}
}
Hope this sheds some light on it.
Mark
"Ginny Caughey [MVP]" <ginny.caughey.online@xxxxxxxxxxxxxx> schreef in
bericht news:Ouv5r2elGHA.4308@xxxxxxxxxxxxxxxxxxxxxxx
Mark,
If you have a *small* sample of code that illustrates what you're trying
to do I'll be glad to have a look at it. I also prefer SqlCeResultSet not
only for speed but also because it's generally a lot easier to use, but I
haven't run into the problem you're describing so I'm curious exactly
what you're doing.
--
Ginny Caughey
.NET Compact Framework MVP
"Mark Huisinga" <mhuisinga@xxxxxxxxxxxxxxxxx> wrote in message
news:Farmg.32173$UQ2.12865@xxxxxxxx
Hi Ginny,
Actually there is no "new" resultset. What I'm doing is when the user
enters a categoryid in the lostfocus event of the textbox I do a seek on
the resultset. If a category id is found I want to update the
bindingsource to the same position as the resultset.
I prefer the sqlceresultset because it is faster on the device with
large tables.
Mark
"Ginny Caughey [MVP]" <ginny.caughey.online@xxxxxxxxxxxxxx> schreef in
bericht news:eWgTxsVlGHA.3528@xxxxxxxxxxxxxxxxxxxxxxx
Mark,
What if you just set the DataSource to the new result set? Or use a
DataTable instead of a result set?
--
Ginny Caughey
.NET Compact Framework MVP
"Mark Huisinga" <mhuisinga@xxxxxxxxxxxxxxxxx> wrote in message
news:yefmg.23811$UQ2.22061@xxxxxxxx
Ginny,
I tried that, but setting the bindingresource to null resulst in an
ArgumentException without an errormessage ( the source assembly cannot
be found).
Mark
"Ginny Caughey [MVP]" <ginny.caughey.online@xxxxxxxxxxxxxx> schreef in
bericht news:%236F1$IVlGHA.3396@xxxxxxxxxxxxxxxxxxxxxxx
Mark,
Probably the best way would be to set the BindingSource.DataSource to
null, then set it back to your new resultset.
--
Ginny Caughey
.NET Compact Framework MVP
"Mark Huisinga" <mhuisinga@xxxxxxxxxxxxxxxxx> wrote in message
news:6%dmg.22179$UQ2.2647@xxxxxxxx
Ginny,
Ok, that is too bad. I have tried to achieve something similar by
using the sqlceresult seek method, however I then have no idea of
how to update the bindingsource so that my controls show the correct
record. Is this at all possible ?
thanx,
Mark
"Ginny Caughey [MVP]" <ginny.caughey.online@xxxxxxxxxxxxxx> schreef
in bericht news:u$MjhaUlGHA.3816@xxxxxxxxxxxxxxxxxxxxxxx
Mark,
I think it's probably a limitation of the SqlCeResultSet since it
doesn't contain the actual data and only maintains pointers to the
data (unlike DataSet). Similarly Sort is also not supported I
believe.
--
Ginny Caughey
.NET Compact Framework MVP
"Mark Huisinga" <mhuisinga@xxxxxxxxxxxxxxxxx> wrote in message
news:_Tcmg.19470$UQ2.9875@xxxxxxxx
Bindingsource.find(..) doesn't seem to work on a bindingsource
with as datasource a sqlceresultset.resultview. As far as I can
tell this is odd since the sqlceresultset.resultview does
implement IBindingList. Or is this a limitation of the
compactframework ?
Mark.
.
- References:
- Bindingsource Find method
- From: Mark Huisinga
- Re: Bindingsource Find method
- From: Ginny Caughey [MVP]
- Re: Bindingsource Find method
- From: Mark Huisinga
- Re: Bindingsource Find method
- From: Ginny Caughey [MVP]
- Re: Bindingsource Find method
- From: Mark Huisinga
- Re: Bindingsource Find method
- From: Ginny Caughey [MVP]
- Re: Bindingsource Find method
- From: Mark Huisinga
- Re: Bindingsource Find method
- From: Ginny Caughey [MVP]
- Re: Bindingsource Find method
- From: Mark Huisinga
- Bindingsource Find method
- Prev by Date: Re: toggle wifi
- Next by Date: Re: toggle wifi
- Previous by thread: Re: Bindingsource Find method
- Next by thread: Re: Bindingsource Find method
- Index(es):
Loading