Re: DataReader Seek

From: Darren Shaffer (darrenshaffer_at_discussions.microsoft.com)
Date: 01/26/05


Date: Tue, 25 Jan 2005 21:33:32 -0700

Jeff,

I just emailed you a sample CF app (CAB and source) that loads your database with bogus item data and
uses the Seek method to return item description by itemID. Worked with CF 1.0 SP2 and SP3.

Darren Shaffer
Principal Architect
Connected Innovation

"Jeff" <jeff@newsgroup.nospam> wrote in message news:%23ZuBWGl$EHA.2180@TK2MSFTNGP10.phx.gbl...
  I am getting a NullReferenceException when using the Seek function of the datareader and I cannot figure out why. I have verified everything I can think of including Index name, etc. I checked the database to make sure that a value of "9" was in the column that is indexed and it is. All of this is in a try block - when it gets to rdr.Seek(DbSeekOptions.FirstEqual, 9) it throws the error. I am running .netcf 1.0 sp3 in case that matters. Here is my code:

  SqlCeConnection cn2 = new SqlCeConnection(@"Data Source=\Program Files\TestApp\Items.sdf");

  cn2.Open();

  //myItems is the table name
  SqlCeCommand cmdSelect2 = new SqlCeCommand("myItems",cn2);
  cmdSelect2.CommandType = CommandType.TableDirect;

  cmdSelect2.IndexName = "ItemIDNdx";

  SqlCeDataReader rdr = cmdSelect.ExecuteReader();

  // the next line throws a NullReferenceException

  rdr.Seek(DbSeekOptions.FirstEqual, 9);

  rdr.Read();

  myDesc = rdr["itemID"].ToString();

  This is driving me crazy - am i missing something?

  Thanks much.



Relevant Pages

  • Re: Capitalise words?
    ... > If a user wants to put a bogus name, ... > maintaining this database, requires some help from the system it's self. ... I know that Jannie Van ... if you capitalize the words then ...
    (alt.php)
  • Re: include_once() within a function
    ... Mikhail Kovalev wrote: ... I've never had a PHP file take that long! ... It loads a 1,8 MB array stored as serialized in a file....=) ... A relational database would speed things up considerably. ...
    (comp.lang.php)
  • Re: Setting drop-down box to database value
    ... You would have to have a recordset that loads the values into the dropdown, ... Total_Hours is a drop-down box. ... | the value stored in the database. ...
    (microsoft.public.frontpage.programming)
  • Getting a list of static objects.
    ... I have a test application that loads some data from a database. ... is then iterated a number of times, and the memory consumption of the ... stack variable is holding a reference (I use static variables heavily for ...
    (microsoft.public.dotnet.framework)
  • Re: AMD or Intel?
    ... Raid with two clusters, one for database and one for xlog. ... Loads and loads ... Are we better off getting AMD processors, ...
    (freebsd-performance)