Solved

using stored procedures to display in a data grid

Posted on 2004-10-13
1
146 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
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…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now