Re: DataReader Seek
From: Darren Shaffer (darrenshaffer_at_discussions.microsoft.com)
Date: 01/26/05
- Next message: rashmi uz via SQLMonster.com: "problem with retriving data"
- Previous message: GTDriver: "How to create a Database in SQL Server CE???"
- Messages sorted by: [ date ] [ thread ]
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.
- Next message: rashmi uz via SQLMonster.com: "problem with retriving data"
- Previous message: GTDriver: "How to create a Database in SQL Server CE???"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|