This is a migrated thread and some comments may be shown as answers.

an item with the same key has already been added

14 Answers 836 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 16 Mar 2011, 08:00 PM
I have read several threads regarding this error but have not found one similar to what I am experiencing. I am creating several reports for an application and therefore copy/paste (using a telerik prescribed method). I was able to do this for one report, make some modifications and quickly create a new report that has the same style as the original. I went to add the third and on this one I got this error. 

At first I thought there was an issue with duplicate field names, etc. However, this didn't really make sense as their definitions are "private". After deleting fields, etc and getting no where, I ended determining the the issue is related to the sql query string. When I go to configure the datasource using the wizard, I enter the query string and when I attempt to click "Execute Query" this error display. In this query I am selecting similar column names from the database. I renamed the datasource name property and still no luck. Why would my query cause this? I have listed them below. BTW... both queries execute fine in SQL Server Management Studio.

See attachment.

sqlDataSource1
SELECT Groups.*, Softrip.dbo.Suppliers.SupplierName 
FROM Groups LEFT OUTER JOIN Softrip.dbo.Suppliers ON
Groups.SupplierID = Softrip.dbo.Suppliers.SupplierID

sqlDataSource4
SELECT StatusChange.*, Groups.*, Softrip.dbo.Suppliers.SupplierName
FROM StatusChange LEFT OUTER JOIN Groups ON
StatusChange.GroupID = Groups.GroupID LEFT OUTER JOIN Softrip.dbo.Suppliers ON
Groups.SupplierID = Softrip.dbo.Suppliers.SupplierID
  

14 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 21 Mar 2011, 05:07 PM
Hello John,

You've pretty much narrowed it down. The exception can occur if you are selecting columns with the same names from the database. Use SQL Server Management Studio to see the names of all columns and rename the ones with matching names as necessary. It might be necessary to delete the SqlDataSource component from the report, save it and reopen the project in Visual Studio in order for the changes to take effect.

All the best,
Steve
the Telerik team
0
Chris @ Intrinsic
Top achievements
Rank 1
answered on 10 Jun 2011, 12:28 AM
I'm getting the same error.  What do you mean by 'similar' field names.  How many characters can be similar?  Some of my fields are the same name up to a point.(like invoice_num  and Serv_invoice_num.)  I can't really see that names that are similar should affect anything.


0
Steve
Telerik team
answered on 10 Jun 2011, 08:46 AM
Hello Chris,

Please install the latest internal build (available in your account) where we made a fix that might be related to this problem. If the issue persists after this, please provide your sql query here, so we can pinpoint the problem.

Regards,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chris @ Intrinsic
Top achievements
Rank 1
answered on 10 Jun 2011, 08:14 PM
No, that is not the solution.

There was duplicate fields in the query.  I removed that and at least the sqldatasource didn't return any errors when I created it and added to the report.  but, after creating a sqldatasource that works and I can test it by executing the query when running the wizard.  Now, when I add a textbox to the report, and I click on the value elipsis, and then fields, I see a grey icon with 'No Data Source' beside it.  Interesting how a datasource is added to the report, and you can't even use it? 

What exactly did I miss?

0
Steve
Telerik team
answered on 13 Jun 2011, 08:17 AM
Hello Chris,

Did you add the SqlDataSource Component as DataSource for the Data Item you're using? When you drag & drop a Data Source Components to the report, you need to assign it as DataSource to a data item in order to have access to the fields.

All the best,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chris @ Intrinsic
Top achievements
Rank 1
answered on 13 Jun 2011, 06:12 PM
Ok.  You mean assign the sqldatasource to the report.  Not the data item.  I just noticed the datasource property of the report itself, so I set that and it worked fine.    But, in the tutorials, it doesn't say to assign the datasource to the report.  I guess the wizard would do that automatically.  But, I would naturally assume that it's automatically assigned when you add a sqldatasource to the report, as there is only allowed to be one sqldatasource assigned to a report.
0
Steve
Telerik team
answered on 14 Jun 2011, 07:52 AM
Hi Chris,

I meant the Data Item in my previous post and if you look at the link you would notice the Report itself is a data item. If you start the Data Source Wizard from the DataSource property of the data item itself or from the Report/Table wizards, then yes, it would be automatically set as DataSource. However, when you drag & drop a Data Source Component to the report, you need to assign it as DataSource to a data item in order to have access to the fields.

Greetings,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chris @ Intrinsic
Top achievements
Rank 1
answered on 14 Jun 2011, 07:19 PM
Thanks for the clarification.  Now, the report is working fine.  The export function is working well, which is great.  But, the print functionality doesn't work by default.  Is there a property I can set to enable the printing button on the report?

Thank you.
0
Steve
Telerik team
answered on 15 Jun 2011, 07:43 AM
Hello Chris,

Should I assume that you are using the Web Report Viewer? If that is the case, the true print functionality depends on the Acrobat PDF plug-in i.e. you should have Acrobat (Reader or Pro version) installed and its PDF plug-in enabled in the browser. If that is not so, the print button would still work but the print would degrade to the browser built-in print. In other words it would print only the visible part of the report in the viewer.

Kind regards,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chris @ Intrinsic
Top achievements
Rank 1
answered on 15 Jun 2011, 06:23 PM
Yes, it's the Web Report Viewer.  But,  I have Acrobat reader installed, and the pdf plug-in is enabled, as I can view any pdf documents directly in the browser (IE 7).  I bring up the report, then press the print button and nothing at all happens, no browser window popups, no printing, nothing.  Yet, I can print from any pdf page or any document at all, so printing is working fine, except for telerik report printing.  What coding do I have to do to actually get that print button to work?  I thought it would be enabled by default, as the export functionality works 100% by default.

0
Steve
Telerik team
answered on 16 Jun 2011, 08:22 AM
Hello Chris,

If the viewer does not detect the plug-in, it would open the default browser print dialog. If that is not happening, then there might be various reasons that disallow the print dialog to be opened from your browser e.g.:

  • Disable Print menu in IE group policy
  • disabled javascript
  • disabled pdf plugin for that browser
  • make sure that there are no other plug-ins with the same functionality, e.g. Foxit. Sometimes it may happen that they tamper with each other.
You can easily verify whether this problem is specific to IE, by trying the same on another browser (e.g. Firefox) and also detect if this is something specific in your app by trying to print from our online examples.
All the best,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chris @ Intrinsic
Top achievements
Rank 1
answered on 13 Jul 2011, 09:53 PM

it's definitely not what you mentioned there.  Shouldn't it come up with a standard print dialog box when you click the print button from the report viewer?  Nothing happens.  It just communicates with the server when you press the print button, and then nothing.   So, there's got to be some setting in the report viewer to turn on printing, or some setting that I missed.  Is it a bug?  I just open a browser window popup with the report viewer in it.  Everything works on that report viewer except for printing.  And, I tried firefox, and IE7.  Pdf plugins are installed, javascript is enabled, Print Menu is enabled, as I can print any webpage from the browser print menu.  It's got to be the report viewer settings or something like that.

 

Thank you.

 

0
Steve
Telerik team
answered on 14 Jul 2011, 08:13 AM
Hello Chris,

We've not encountered a case where the print button does not do anything at all, but everything else functions correctly. You can use Fiddler to see what is the request sent from the browser and what is the response from the server, use the Instectors for this purpose. That should give you a clue what is happening.

Regards,
Steve
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Chris @ Intrinsic
Top achievements
Rank 1
answered on 15 Jul 2011, 06:36 PM

Hi Steve.  I'll try that, but not sure what I would find.  I guess I would see just the wrong information sent to the server.  But, in Firebug, I see the generated code here:

<div title="Print" id="MainPanel_rpvInvoiceSummary_ReportToolbar_PrintGr_Print">
                            <table cellspacing="0" cellpadding="0" style="border-collapse: collapse;" class="NormalButton" id="MainPanel_rpvInvoiceSummary_ReportToolbar_PrintGr_Print_Button">
                                <tbody><tr>
                                    <td class="ImageButtonCell" unselectable="on"><input type="image" onclick="return false;" src="/CFM-SPP/Telerik.ReportViewer.axd?optype=Resource&version=5.0.11.316&name=Skins.Default.Print.gif" class="Enabled" title="Print" name="ctl00$MainPanel$rpvInvoiceSummary$ReportToolbar$PrintGr$Print$ctl00"><input type="image" onclick="return false;" src="/CFM-SPP/Telerik.ReportViewer.axd?optype=Resource&version=5.0.11.316&name=Skins.Default.PrintDisabled.gif" class="Disabled" title="Print" name="ctl00$MainPanel$rpvInvoiceSummary$ReportToolbar$PrintGr$Print$ctl01"></td>
                                </tr>
                            </tbody></table>
                        </div>

Does this look correct?
Tags
General Discussions
Asked by
John
Top achievements
Rank 1
Answers by
Steve
Telerik team
Chris @ Intrinsic
Top achievements
Rank 1
Share this question
or