Re: DataReader Seek
From: Darren Shaffer (darrenshaffer_at_discussions.microsoft.com)
Date: 01/20/05
- Next message: scott kramer via SQLMonster.com: "Re: Removing rows on subscribers, but not on publishers"
- Previous message: Jeff: "Re: DataReader Seek"
- In reply to: Jeff: "Re: DataReader Seek"
- Next in thread: Jeff: "Re: DataReader Seek"
- Reply: Jeff: "Re: DataReader Seek"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 19 Jan 2005 21:08:41 -0700
Jeff,
I looked back through three or four code sections I have written using the Seek method on live projects
and syntax-wise you are right on the mark. The only thing I can think of that would produce a
null reference would be if there is not actually a value of 9 in the index you are using. It sounds
like there is though.
Assuming there is no sensitive data within, if you want to email me a copy of your .sdf, I'd be happy to
figure it out for you. I'm doing an MSDN webcast on 3/2 on SQL CE and would like to know if there is a
problem with CF sp3 and SQL CE 2.0, so I'd really like to look into this in detail.
ddshaff@nospam.hotmail.com
--
Darren Shaffer
Principal Architect
Connected Innovation
www.connectedinnovation.com
"Jeff" <jeff@newsgroup.nospam> wrote in message news:eHaD4Gn$EHA.3236@TK2MSFTNGP15.phx.gbl...
Thanks for the quick response Darren. I gave it a try with your change and got the same result. I tried compacting the database and renaming back to the original name and got the same result. Any other ideas?
"Darren Shaffer" <darrenshaffer@discussions.microsoft.com> wrote in message news:O7wEUMm$EHA.2552@TK2MSFTNGP09.phx.gbl...
Jeff - your code looks correct to me, but give this a try:
rdr.Seek(DbSeekOptions.FirstEqual, new object[] {9} );
Strictly speaking, the second param of the seek method requires an object, so either use
the array notation above or do a new SqlInt32 and set it to a value of 9.
Pls let me know how this works for you.
-- Darren Shaffer
"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: scott kramer via SQLMonster.com: "Re: Removing rows on subscribers, but not on publishers"
- Previous message: Jeff: "Re: DataReader Seek"
- In reply to: Jeff: "Re: DataReader Seek"
- Next in thread: Jeff: "Re: DataReader Seek"
- Reply: Jeff: "Re: DataReader Seek"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|