Databinding error using LINQDatasource with stored procedure

  • Thread starter Alex. O. Koranteng
  • Start date

A

Alex. O. Koranteng

I am using a stored procedure to bind to a LINQDatasource to populate gridview.
I am getting the error shown below when the stored procedure is executed. I
do not see where the method GetProductsResult is coming from. I have provided
the synatx for the SPROC. dbo.Get Products as follows:


USE [AdventureWorks]
GO
/****** Object: StoredProcedure [dbo].[GetProducts] Script Date:
06/07/2009 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

/* Gets the customer information */
ALTER PROCEDURE [dbo].[GetProducts]

AS
SET NOCOUNT ON;

SELECT
ProductID, Name, rowguid, ModifiedDate
FROM
Production.Product

[Function(Name="dbo.GetProducts")]
public ISingleResult<GetProductsResult> GetProducts()
{
IExecuteResult result = this.ExecuteMethodCall(this,
((MethodInfo)(MethodInfo.GetCurrentMethod())));
return ((ISingleResult<GetProductsResult>)(result.ReturnValue));
}

Error Message

Server Error in '/LinqDataSourceExampleCode1' Application.
--------------------------------------------------------------------------------

No property or field 'rowguid' exists in type 'GetProductsResult'
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Web.Query.Dynamic.ParseException: No property or
field 'rowguid' exists in type 'GetProductsResult'

Source Error:
 
Ad

Advertisements

M

Mr. Arnold

Alex. O. Koranteng said:
I am using a stored procedure to bind to a LINQDatasource to populate
gridview.
I am getting the error shown below when the stored procedure is executed.
I
do not see where the method GetProductsResult is coming from. I have
provided
the synatx for the SPROC. dbo.Get Products as follows:



Error Message

Server Error in '/LinqDataSourceExampleCode1' Application.
--------------------------------------------------------------------------------

No property or field 'rowguid' exists in type 'GetProductsResult'
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.Web.Query.Dynamic.ParseException: No property or
field 'rowguid' exists in type 'GetProductsResult'

Source Error:

The GetProductResult is the returned result of dbo.GetProduct a sproc query,
just like you would get a resultset back from a ADO.NET SQL Command object,
if it executed the sproc. But the resultset would have no name, which you
would use a datareader to read the resultset, if using ADO.NET SQL Command
object.



__________ Information from ESET NOD32 Antivirus, version of virus signature database 4136 (20090606) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
A

Allen Chen [MSFT]

Hi Alex,
Exception Details: System.Web.Query.Dynamic.ParseException: No property or
field 'rowguid' exists in type 'GetProductsResult'

First I suggest you read documentation below to learn how to use
LinqDataSource & stored procedure:

http://msdn.microsoft.com/en-us/library/bb547113.aspx

If it still doesn't work please send me your current project. My email is
(e-mail address removed). Please update here after sending the project in case
I missed that email.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Alex. O. Koranteng

Allen,

Thanks for the information. I'll review that link and update you by Wednesday
 
A

Allen Chen [MSFT]

Hi Alex,
Thanks for the information. I'll review that link and update you by
Wednesday

Have you solved this issue?

Regards,
Allen Chen
Microsoft Online Support
 
Ad

Advertisements

A

Alex. O. Koranteng

Allen,

I have reviewed the link and still cannot get it to work. I will be emailing
to your inbox the sample application and thanks for your suport
 
A

Allen Chen [MSFT]

Hi Alex,
I have just emailed the sample application to your inbox.
Thanks


Thanks for your project. I see what the problem is. You create the stored
procedure in the designer by dragging the stored procedure from the Server
Explorer window and build the web site, right? At the first time the stored
procedure has no rowguid returned therefore designer assume you don't need
that field and will not generate the rowguid property in the
GetProductsResult class. However, you've now added that field in your
stored procedure. Because the existing GetProductsResult class doesn't
contain that property the exception is thrown.

To solve this problem, please double click AdventureWorksDatabase.dbml, in
the designer, delete the stored procedure and build web site. Then add the
stored procedure again by dragging it from Server Explorer window to the
designer of AdventureWorksDatabase.dbml. At last build web site again.
Check the GetProductsResult class. It should contain rowguid property now.
Start debugging, everything should be working.

Regards,
Allen Chen
Microsoft Online Support
 
A

Alex. O. Koranteng

Allen,

it work per your suggestions. Now I know that you have to build the dbml
file and the solution, then add the SPROC. I was running the sample as is
form the www.Devx.com forums. What is the difference between dragging the
SPROC from server explorer to the dbml file designer window and dragging it
to the methods pane the documentation says. Also, I will appreciate and good
links on using SPROCS with LINQdatasource. Also, you mentioned that I should
check the GetproductsResult class. How Do I do this. Do I use debugger.
Again, I have a always admired your efforts to help me.

Alex
 
A

Allen Chen [MSFT]

Hi Alex,
What is the difference between dragging the
SPROC from server explorer to the dbml file designer window and dragging it
to the methods pane the documentation says.

I'm not sure what the methods pane is. But whatever you do the designer
will connect database to retrieve information about the SPROC and generate
code for Linq to Sql usage. You can view the generated code in
AdventureWorksDatabase.designer.cs. (If you like you can edit the generated
code to meet your specific requirement) You can find this file in the
Solution Explorer window by expanding the AdventureWorksDatabase.dbml node.
Also, I will appreciate and good
links on using SPROCS with LINQdatasource.

You can refer to the documentation mentioned in my previous post:

http://msdn.microsoft.com/en-us/library/bb547113.aspx

There's a chapter called Using Stored Procedures addressing this issue.
Also, you mentioned that I should
check the GetproductsResult class. How Do I do this. Do I use debugger.

You can find GetproductsResult class in AdventureWorksDatabase.designer.cs.


Regards,
Allen Chen
Microsoft Online Support
 
Ad

Advertisements

A

Alex. O. Koranteng

Allen,

Thanks for your support and explanations on this incident. I also appreciate
the link reference on using Stored procs. You may close this case.
 
Ad

Advertisements

A

Allen Chen [MSFT]

You're welcome. Have a nice day!


Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top