Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

using stored procedures to display in a data grid

Posted on 2004-10-13
1
Medium Priority
?
191 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 1000 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
Suggested Courses

916 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