473,803 Members | 3,886 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

execute a stored procedure with parameter from .net

23 New Member
hi

how can if call a strored prosedure from sql server with parameters


my procedure is



ALTER PROCEDURE [dbo].[search_proced] ( @p_version nvarchar(100),
@p_result nvarchar(100),
@Salesman int , @from_Date datetime ,
@to_date datetime )



and i have to use the result in gridview


10x for helping me
Sep 18 '07 #1
2 1115
Plater
7,872 Recognized Expert Expert
Use the SQLCommand object.
Here's how I do it:
Expand|Select|Wrap|Line Numbers
  1. DataTable retval = new DataTable();
  2. //dbcon is your database connection object
  3. SqlCommand sc = new SqlCommand("search_proced", dbcon);
  4. sc.CommandType = CommandType.StoredProcedure;
  5. sc.Parameters.Add("@p_version", SqlDbType.NVarChar);
  6. sc.Parameters["@p_version"].Value = "Something";
  7. //
  8. //repeat for your other parameters
  9. //
  10. SqlDataAdapter sda = new SqlDataAdapter(sc);
  11. sda.Fill(retval);
  12. sc.Dispose();
  13. sda.Dispose();
  14. //now "retval" is a DataTable that can be used as a DataSource for your GridView;
  15.  
  16.  
hi
how can if call a strored prosedure from sql server with parameters
my procedure is
ALTER PROCEDURE [dbo].[search_proced] ( @p_version nvarchar(100),
@p_result nvarchar(100),
@Salesman int , @from_Date datetime ,
@to_date datetime )
and i have to use the result in gridview


10x for helping me
Sep 18 '07 #2
simonakiki
23 New Member
10x Plater for helping me

i tested ur script and it work fine;
Sep 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
15484
by: PJ | last post by:
<% Set Conn = Server.CreateObject("ADODB.Connection") Conn.open application("dtat_motor_connectionstring") set rs = new adodb.recordset 'Set RS = Conn.Execute(' "exec spcn_update_transactions & customer_number, customer_name, customer_address, customer_city, customer_state, customer_zip, customer_phone, vin, acct_number, tag, title_number, tag_type_number, branch_number, institution_number, yr_make, state_from, type_number)...
4
3519
by: Noloader | last post by:
Hello, Access XP, SQL Server 2000 Is it possible to hide a SP under Queries in Access, yet still be able to Execute it from Access? We hooked up a custom form to accept the input parameters (MS Feature Request!) for the Stored Procedure. We had two problems with MS's 'Input Parameter' dialog: 1) We could not customize, 2) We continually
2
2042
by: Noloader | last post by:
Hello, Access XP, SQL Server 2000 Is it possible to hide a SP under Queries in Access, yet still be able to Execute it from Access? (Similar to hiding Tables, then using Views) We hooked up a custom form to accept the input parameters (MS Feature Request!) for the Stored Procedure. We had two problems with MS's
2
3336
by: Eli | last post by:
Hi all We currently have a strange problem with calling a Stored Procedure (SQL Database) in our C# Project. The only error I get is "System error" which says a lot :) Background: We have several stored procedures to Insert and update datas in our SQL database. Some stored procedures are smaller (insert datas in only one table) and some of them are quite big (insert datas in several
1
5961
by: shsandeep | last post by:
I 'recreated' a stored procedure. Earlier, i had given privileges to a particular group but now (after rebuilding) when I try to grant execute privilege for the SP to the same user group, it gives me the below message. Any clues on this?? SQL0458N In a reference to routine "SITSCHM.SP_ERND_PREM" by signature, a matching routine could not be found. SQLSTATE=42883
0
9700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.