Re: how to use Store Procedure in VC# 2005 and SQL 2005 ?
Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance
Hi hamed,
first of all, you have to create the stored procedures on your sql-server
with help of query analyser:
CREATE PROCEDURE your_insert_sp
(@field1 [int],
@field2 [nvarchar](15)
AS INSERT INTO Categories
( [field1],
[field2]
VALUES
(@field1,
@field2
GO
to use these stored procedured in c# you can do the following:
SqlConnection con = new SqlConnection(<your constring>);
con.Open();
SqlCommand cmd = new SqlCommand("your_insert_sp", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteScalar();
con.Close();
hope it helps
marcel beutner
PS: the parameters @field1 and @field2 must define in the
SqlParameterCollection of your command object
.
Relevant Pages
- Extreme performance issues (SQL Server 2000/ADO.NET/C#)
... same exact stored procedures and views, run in the same exact order, through ... system that runs SQL Server (a 4-cpu Xeons system with 2gigs of physical ... When I execute these steps manually through query analyser,, ... (microsoft.public.sqlserver.server) - Re: SQL Problem
... My Access db is distributed to one user for input and about a dozen users ... I should bone up on stored procedures. ... >>Did I mention that my Access query includes queries, ... > as stored procedures in SQL-Server. ... (microsoft.public.dotnet.general) - Re: Insert into Sonderzeichen
... Verwende Stored Procedures und erfreue Dich an dem vom ... dass das ganze nur mit einem SQL-Server funktioniert. ... Solltest Du aber eine ACCESS DB verwenden, ... (microsoft.public.de.german.entwickler.dotnet.vb) - Infomessage in ADO Connection
... I am trying to use the OnInfomessage event for TADOConnection to catch ... messages coming from stored procedures in SQL-Server. ... I am using SQLOLEDB and the connections CursorLocation is set to ... (borland.public.delphi.database.ado) - Re: Odbc connections and ADP?
... If you don't want to use ADO, then there is the possibility of setting up ... the connection to the Oracle Server directly on the SQL-Server and perform ... your queries to Oracle from stored procedures. ... (microsoft.public.access.adp.sqlserver) |
|