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

Connecting RadGrid to Stored Procedure

4 Answers 400 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Abby
Top achievements
Rank 1
Abby asked on 20 Mar 2009, 01:14 PM
I'm trying to connect a radgrid (rgCompDetail) to a stored procedure and I cannot get the records to display.  My stored procedure produces a 2 column grad with 5 lines. 

here's the code I'm attempting.  Any suggestions/corrections? 


 

Dim strConn2 As String = regKey.GetValue("DotNetConnectionString")

 

Dim sConn2 As New SqlConnection(strConn2)

 

 

 

Dim drDetail2 As SqlDataReader

 

 

 

Dim cmdShipdata As New SqlCommand("sp_ShipDetailInCompanyFields", sConn2)

 

 

 

cmdShipdata.CommandType = CommandType.StoredProcedure

cmdShipdata.Parameters.AddWithValue(

"@ProjectId", ProjectID)

 

 

cmdShipdata.Parameters.AddWithValue(

"@Company_Id", CustomerId)

 

 

 

sConn2.Open()

drDetail2 = cmdShipdata.ExecuteReader

 

rgCompDetail.DataSource = drDetail2

rgCompDetail.DataBind()

 

 


4 Answers, 1 is accepted

Sort by
0
Abby
Top achievements
Rank 1
answered on 23 Mar 2009, 03:04 PM
No one knows how to do this???
Help, please....
0
Rosen
Telerik team
answered on 23 Mar 2009, 03:37 PM
Hi Abby,

Please refer to this online demo for an live example of how to bind RadGrid to a DataReader instance. Also you may review the Binding To DataReader help article in our documentation.

Kind regards,
Rosen
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Abby
Top achievements
Rank 1
answered on 23 Mar 2009, 03:46 PM
Thank you for your response Rosen. 
I've already read the article & looked at the demo you suggested.
I'm still confused as none of these examples bind to a stored procedure - they are connecting to the database directly or manually typing a table. 
I do not understand what is wrong with my code below that the radgrid does not display on my screen whatsoever - it's almost as if it does not exist.
0
Rosen
Telerik team
answered on 26 Mar 2009, 10:06 AM
Hello Abby,

I have attached a simple page which binds a RadGrid to a Northwind storeprocedure using a DataReader. Please give it a try and let  me know if I'm missing something obvious.

Also if you continue to experience difficulties please paste your SP's definition.

All the best,
Rosen
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Abby
Top achievements
Rank 1
Answers by
Abby
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or