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 / July 2008

Tip: Looking for answers? Try searching our database.

Help: dupe param error with SqlCeCommand:

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matt - 23 Jul 2008 15:20 GMT
Argh!  I am getting "duplicate parameter" errors with the following
prepared SqlCeCommand:  (The important line is the next to the last line
with @kid_id).

select e.entry_id,    
    convert(nvarchar(10), e.entry_date, 101),    
    e.entry_title,    
    e.entry_text,    
    e.minutes_spent,    
    e.entry_date
from ud_entry as e
where e.entry_date >= @start_date      
    and e.entry_date <= @end_date      
    and exists
        (select *
        from ud_entry_to_kid as iek
        where e.entry_id = iek.entry_id
            and (iek.kid_id = @kid_id or @kid_id = -1) )
order by e.entry_date, e.priority

If I try to run this, I get:
{"Duplicated parameter names are not allowed. [Parameter name =
@kid_id]"}

If I remove the "or @kid_id = -1", the command compiles and runs
correctly.  Apparently, I can only put the @kid_id parameter in the
query once.  From the behavior, this seems like a deliberate limitation.
(!)

Has anyone seen this before?  Suggestions for working around?

Using SQL CE 3.1.

Thanks for any advice.

Matt

partial stack trace:

Duplicated parameter names are not allowed. [  Parameter name = @kid_id
]
  at System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan()
  at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand
(CommandBehavior behavior, String method, ResultSetOptions options)
  at System.Data.SqlServerCe.SqlCeCommand.ExecuteDbDataReader
(CommandBehavior behavior)
  at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader
(CommandBehavior behavior)
  at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
  at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables,
Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior
behavior)
  at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
Jin - 24 Jul 2008 02:02 GMT
> Argh!  I am getting "duplicate parameter" errors with the following
> prepared SqlCeCommand:  (The important line is the next to the last line
[quoted text clipped - 51 lines]
> behavior)
>    at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)

If I read the situation correctly, then simply using a different
parameter name (i.e. @kid_id2) should do the trick.
After all, these parameters are simply placeholders.  Just make sure
you reference the same parameter name when supplying the actual
values.

- Jin
Matt - 24 Jul 2008 05:26 GMT
Jin <jinsoochang@gmail.com> wrote in news:689f4ae3-1393-44b3-bcd2-
6d9614de2a44@t54g2000hsg.googlegroups.com:

<snip "Duplicated parameter names are not allowed" discussion>

> If I read the situation correctly, then simply using a different
> parameter name (i.e. @kid_id2) should do the trick.
[quoted text clipped - 3 lines]
>
> - Jin

Doh!  You do read the situation correctly, and simply adding another
parameter with a different name but the same value does solve the problem.

I feel silly that I didn't think of this myself, but thank you very much
for the suggestion.

Matt
 
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



©2008 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.