Solved

using stored procedures to display in a data grid

Posted on 2004-10-13
1
171 Views
Last Modified: 2010-04-07
I have a stored procedure written in SQLSErver 2000 that accepts input parameters and the select statement in the stored procedure uses multiple tables to fllter records based on the inpput parameters.  
I have to use this stored procedure to display in the datagrid based on the search criteria entered by the user.
I am using Visual studio.net /C#.net
Can u please help me to complete this task.
Thanks.
0
Comment
Question by:miyengar
1 Comment
 
LVL 18

Accepted Solution

by:
tusharashah earned 500 total points
ID: 12308608
Call following method:

--------------------------------------------------------------------------------------------------------------------------------------------
BindDataGrid()
{
  DataSet objDS = new DataSet();
  SqlCommand objCommand = new SqlCCommand ( "YourStoredProcedure", "YourConnectionString" );
  objCommand.CommandType = CommandType.StoredProcedure;

  SqlDataAdapter objAdapter = new SqlDataAdapter();
  objAdapter.SelectCommand = objCommand;

  objAdapter.SelectCommand.Parameters.Add("@ParameterName", SqlDbType.VarChar, 100).Value = "ParameterValue";

  objAdapter.Fill ( objDS );

  DataGrid1.DataSource =  objDS.Tables[0];
  DataGrid1.DataBind();
}
--------------------------------------------------------------------------------------------------------------------------------------------

-tushar
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can I access internet from laptop via my cell phone? 8 216
Code Editors 10 216
HTML Editor to Choose? (2015) 13 85
Web Development Tools for MVC 3 111
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question