Solved

using stored procedures to display in a data grid

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
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…
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…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

831 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