Solved

using stored procedures to display in a data grid

Posted on 2004-10-13
1
179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
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 automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
Suggested Courses

623 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