473,471 Members | 1,684 Online
Bytes | Software Development & Data Engineering Community
Create 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 1091
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
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 &...
4
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...
2
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...
2
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...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.