Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server CE / May 2008

Tip: Looking for answers? Try searching our database.

SQL Compact Edition does not recognize parameter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
d.wiss@gmx.net - 09 May 2008 13:36 GMT
Hi all

I use the following example for the description:
"UPDATE Table SET Column1=@Value1"

In code I create a parameter and add it to a list which is passed to
the execution:
_dbHelper.CreateParameter("@Value1", SqlDbType.NVarChar, 50, "some
text value")

Of course the original table query has more columns and parameter but
it's not necessary to see behind the problem. The query and the
parameters are all written in camel notation.

We are using .NET 2.0, SQL 2005 Compact Edition V3.0.5300.0.

Now the problem:
Our software is installed on tousands of computers, mostly installed
with W2K, XP and recently also Vista.

In Spain we have a problem on several machines and the company there
assured that all computers have the same installation. It's a chain to
selling our products.
On ca. 19 machines (of 50) in different chain shops, if they start our
software it shows following error in the log file:

System.IndexOutOfRangeException
An SqlCeParameter with ParameterName '@himodelleft' is not contained
by this SqlCeParameterCollection.
[System.Data.SqlServerCe]System.Data.SqlServerCe.SqlCeCommand::CompileQueryPlan()

It's always the same error message althought there are 35 parameters
defined in the query and obviously in the provided parameter/value
list. The affected parameter is on index [31] (based on [0]).

This error message tells me that SQLCE lower cases the query text to
"update table set column1=@value1" because the specified parameter
name in the error message is written in lower case.
Therefore I assume that the associated created parameter is converted
to lower case as well.

The following link shows a similar problem but on PDA's with Windows
Mobile installed
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1216930&SiteID=1

Strange are the following two lines:
MODEL        SQLCE             NETCF       O.S.             PROBLEM
QTEK S200  3.0.5214.0        2.0.5238.0   WM5            YES
QTEK 9900   3.0.5214.0        2.0.5238.0   WM5            NO

Only the hardware is different but on one PDA the problem exists
whereas on the other it doesn't!
His solution was to lower case all the parameters and the problem was
gone on the QTEK S200 PDA.

In our case I'm not sure if this would help.

Has anybody else faced to this problem? Any help would be appreciated.

Regards
Daniel
Ginny Caughey MVP - 09 May 2008 14:51 GMT
I haven't run into this problem, I wonder if you can reproduce it yourself?
If so, you might try looking in the debugger to see what the parameters
collection looks like before you execute the query. Sometimes I have found,
also with SQL Server, that I'll get a missing parameter message when in fact
it just has a data type different than what I intend.

Ginny

> Hi all
>
[quoted text clipped - 57 lines]
> Regards
> Daniel

Signature

Ginny Caughey
Device Application Development MVP

www.wasteworks.com
Software for Waste Management

d.wiss@gmx.net - 09 May 2008 15:39 GMT
That's the problem. It isn't reproducable neither on my machine nor on
others within our development and verification team.
And the affected computers are not connected on internet for remote
access.

The column has following properties (from SQL Server Management
Studio):
Name: HIModelLeft
Data Type: nvarchar(50)
Size: 100
Identity: No
Nulls: Yes
Default:

and I do create the parameter like following:
_dbHelper.CreateParameter("@HIModelLeft", SqlDbType.NVarChar, 50,
"some value")

There are lot more columns like this and only this provides us
headaches.

Daniel

On 9 Mai, 15:51, "Ginny Caughey MVP"
<ginny.caughey.onl...@wasteworks.com> wrote:
> I haven't run into this problem, I wonder if you can reproduce it yourself?
> If so, you might try looking in the debugger to see what the parameters
[quoted text clipped - 77 lines]
> www.wasteworks.com
> Software for Waste Management
Ginny Caughey MVP - 09 May 2008 17:47 GMT
Daniel,

One other thing to check is the parameters just above the one causing the
error message. I think I remember seeing that type of error message when one
or more parameters before the one listed was in error. Other than that, I
don't have really have any ideas since it only happens some of the time. It
does sound data related in some way though.

Ginny

> That's the problem. It isn't reproducable neither on my machine nor on
> others within our development and verification team.
[quoted text clipped - 105 lines]
>> www.wasteworks.com
>> Software for Waste Management

Signature

Ginny Caughey
Device Application Development MVP

www.wasteworks.com
Software for Waste Management

d.wiss@gmx.net - 13 May 2008 06:51 GMT
Hi Ginny

Those three lines are directly above of the missing parameter line:

_dbHelper.CreateParameter("@HealthCardNumber", SqlDbType.NVarChar, 50,
p.HealthCardNumber)
_dbHelper.CreateParameter("@DateCreated", SqlDbType.DateTime, 8,
CheckDate(p.DateCreated))
_dbHelper.CreateParameter("@DateLastFitting", SqlDbType.DateTime, 8,
CheckDate(p.DateLastFitting)

The method CheckDate(...) is following code:

private DateTime CheckDate(DateTime date)
{
    if (date.Year > 1800)
        return date;
    else
        return new DateTime(1800,1,1);
}

Thank you for trying to help. I appreciate this very much.
Daniel

On 9 Mai, 18:47, "Ginny Caughey MVP"
<ginny.caughey.onl...@wasteworks.com> wrote:
> Daniel,
>
[quoted text clipped - 127 lines]
> www.wasteworks.com
> Software for Waste Management
d.wiss@gmx.net - 13 May 2008 11:15 GMT
Update:
Our support requested the guy in Spain to change the regional settings
in a first step to "English (United States)" and this solved the
problem.
Unclear is why and this produces more questions:
- What are the regional settings on the computers where the problem
does NOT exists?
- If they are set to Spanish too, why does it work anyway?

The guy in Spain will go to an another shop where the problem exists
and set the regional settings to "English (US)" as well and will
report the result to us.

Daniel

On 13 Mai, 07:51, d.w...@gmx.net wrote:
> Hi Ginny
>
[quoted text clipped - 155 lines]
> >www.wasteworks.com
> > Software for Waste Management
Ginny Caughey MVP - 13 May 2008 12:08 GMT
Daniel,

Thanks for the update. It appears that the lines above (the date) might be
involved then. I don't know why that would cause a problem either, but I bet
you'll figure it out now.

Ginny
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.