HELP: Baffled by bug (?) in SqlCeCommand:
- From: Matt <usenet.junk.000@xxxxxxxxx>
- Date: Mon, 28 Apr 2008 10:00:16 -0700
I am getting strange results running a SqlCeCommand (v3.1) in a .NET
application.
It is a select command, and the bug (?) depends on the first time the
command is used to retrieve results.
If the table is entirely empty, then for the rest of the lifetime of the
SqlCeCommand, the WHERE clause is ignored. Later retrievals using the
command return *all* rows in the table, despite a parameter that is
supposed to filter results to a single day.
If the table has even one row on the first invocation, the command works
correctly for the entire session.
The command is created only once upon app load and reused several times.
I assume this is a bug. Maybe I just did something dumb.
Has anyone seen this before? Any suggestions?
Matt
Code snippets:
Upon app load:
sSQL =
"select entry_id, case len(entry_title) when 0 then '(no title)'
else entry_title end as entry_title, priority "
+ "from ud_entry "
+ "where entry_date = @target_date "
+ "order by priority";
_sqlcmdGetDTitlesAndNewByTargetDate = new SqlCeCommand(sSQL, _sqlConn);
_sqlcmdGetDTitlesAndNewByTargetDate.Parameters.Add("@target_date",
SqlDbType.DateTime);
Upon selecting a new date:
public DataTable GetDTitlesAndNewByDate(DateTime dateTarget)
{
_sqlcmdGetDTitlesAndNewByTargetDate.Parameters
["@target_date"].Value = dateTarget;
DataTable dt = new DataTable();
SqlCeDataAdapter da = new SqlCeDataAdapter
(_sqlcmdGetDTitlesAndNewByTargetDate);
da.Fill(dt);
DataRow dr = dt.NewRow();
dr["entry_id"] = 0;
dr["entry_title"] = "(new entry)";
dr["priority"] = 0;
dt.Rows.InsertAt(dr, 0);
return dt;
}
.
- Follow-Ups:
- Re: HELP: Baffled by bug (?) in SqlCeCommand:
- From: Jin
- Re: Baffled by bug (?) in SqlCeCommand:
- From: Ginny Caughey MVP
- Re: HELP: Baffled by bug (?) in SqlCeCommand:
- Prev by Date: Re: Performance problem in sql ce
- Next by Date: Re: Baffled by bug (?) in SqlCeCommand:
- Previous by thread: SQLServerCE 3.1 and Vista Ultimate
- Next by thread: Re: Baffled by bug (?) in SqlCeCommand:
- Index(es):
Relevant Pages
|
Loading