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

Grid / Hierarchy with Templates

3 Answers 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Walker
Top achievements
Rank 1
David Walker asked on 06 Apr 2010, 04:39 PM
Hello,

I've been following the example given in:


and have encountered the error:

ERROR [42000] [Microsoft][SQL Server Native Client 10.0][SQL Server]Must declare the scalar variable "@EmployeeID".

on execution. My code is virtually identical to the example, only the ConnectionString and ProviderNames have been changed (and the header and footer stuff of course).

Cheers

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 07 Apr 2010, 12:36 PM
Hi David,

As with the hierarchy declarative relations, you should have a WHERE clause in the SelectCommand of the data source control for the nested view template to retrieve the record for it. The WHERE clause should include the field from the ParentTableRelation definition between the master/child table. Furthermore, the same field has to be included in the SelectParameters of the "inner" data source controls with exactly the same Name.

Could you please confirm that you are using SelectParameters?
ASPX:
<SelectParameters>
           <asp:Parameter Name="EmployeeID" />
       </SelectParameters>

I hope this helps.

Greetings,
Pavlina
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
David Walker
Top achievements
Rank 1
answered on 07 Apr 2010, 01:55 PM
Thanks for the reply but if you look at your Example Source Code for that page (http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/nestedviewtemplate/defaultcs.aspx) you will notice that the parameters are ControlParameters:

<asp:SqlDataSource ID="SqlDataSource4" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
ProviderName="System.Data.SqlClient"  
SelectCommand="SELECT BirthDate, Country, City, Address, HomePhone FROM Employees Where EmployeeID = @EmployeeID" 
runat="server"
<SelectParameters> 
    <asp:ControlParameter ControlID="Label1" PropertyName="Text" Type="String" Name="EmployeeID" /> 
</SelectParameters> 
</asp:SqlDataSource> 

not

<SelectParameters> 
<asp:Parameter Name="EmployeeID" /> 
</SelectParameters> 

The problem seems to be that the SqlDataSource is having trouble binding to the control.

Also there is no ParentTableRelation anywhere in the code given. Are you sure that the Example Source Code is correct on this page?

Thanks,
David
0
Pavlina
Telerik team
answered on 12 Apr 2010, 02:08 PM
Hi David,

Could you please open a formal support ticket, and send us a small working project, demonstrating your setup, and showing the error you received?
We will debug it locally, and get back to you with additional information on the matter.

Sincerely yours,
Pavlina
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.
Tags
Grid
Asked by
David Walker
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
David Walker
Top achievements
Rank 1
Share this question
or