Re: Bindingsource Find method



Mark,

Thanks for the small sample so I can see what you mean.

As Ilya says, you can only use a *new* resultset to "filter" the data. For
example if you add something like this as a form variable

SqlCeResultSet newRS;

then you can have code like this to create new resultsets that just show the
single record that matches the value entered.

SqlCeCommand cmd = categoriesResultSet.Connection.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select * from Categories where [Category ID] = '" +
category_IDTextBox.Text + "'";
newRS = cmd.ExecuteResultSet(ResultSetOptions.Scrollable |
ResultSetOptions.Updatable);
categoriesResultSetBindingSource.DataSource = newRS;

I'm not sure this is really what you want though as you can see if you also
add a bound DataGrid to the form.

I'd suggest using a buffer area rather than a live connection to a resultset
to get data from the user. Then you can easily check to see if the Category
ID entered already exists, in which case you can show it, or if it doesn't
in which case you can add it.


--
Ginny Caughey
..NET Compact Framework MVP


"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.



















.



Relevant Pages

  • Re: Bindingsource Find method
    ... Ginny Caughey ... .NET Compact Framework MVP ... Actually there is no "new" resultset. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Bindingsource Find method
    ... Ginny Caughey ... Actually there is no "new" resultset. ... .NET Compact Framework MVP ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Bindingsource Find method
    ... then I'll skip the binding and just use the resultset. ... .NET Compact Framework MVP ... BindingSource on the corresponding record. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Bindingsource Find method
    ... categoriesResultSet is generated.. ... .NET Compact Framework MVP ... Actually there is no "new" resultset. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Performance problem in sql ce
    ... Resultset seems to be work. ... SqlCeResultSet rs = CeCommand.ExecuteResultSet; ... even with the amount of data you have. ... I am very disappointed with the sql queries performance in sql ce. ...
    (microsoft.public.sqlserver.ce)