473,395 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to use Store Procedure in VC# 2005 and SQL 2005 ?

hi
i want to use Store Procedure for Insert,Update and Delete operation in my
c# app, but how to do ??
please give me an example,source or article or ...
thanks
Dec 24 '06 #1
2 1127
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
Dec 25 '06 #2
hi

Did you google this question?

There are examples all over the internet of how to use SP in C#
--
Ignacio Machin
machin AT laceupsolutions com

"Hamed_1983" <Ha*******@discussions.microsoft.comwrote in message
news:93**********************************@microsof t.com...
hi
i want to use Store Procedure for Insert,Update and Delete operation in my
c# app, but how to do ??
please give me an example,source or article or ...
thanks

Dec 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jin | last post by:
Hello: I run one process that calls the following the store procedure and works fine. create PROCEDURE sp_GetHostSequenceNum AS BEGIN SELECT int_parameter_dbf + 1
2
by: serge | last post by:
My project is to automate testing of Stored Procedures of type SELECT (at least for now). I want to create a table where each stored procedure's input parameter values are entered and in another...
0
by: anonieko | last post by:
This approach I found very efficient and FAST when compared to the rowcount, or Subquery Approaches. This is before the advent of a ranking function from DB such as ROW_NUMBER() in SQL Server...
6
by: c676228 | last post by:
Hi everyone, I wrote a store procedure that fetch one row data in the database based on the parameter value I entered. After I created the store procedure, the store procedure code looks like...
0
by: rxding | last post by:
Hello, Performance reason we need to move some of our code into database. Java Store Procedure is given the first choice. However, while investigating some sample code of Java store procedure, ...
11
by: c676228 | last post by:
Hi everyone, I am just wodering in asp program, if there is anybody writing store procedure for inserting data into database since there are so many parameters need to be passed into store...
2
by: Mukesh | last post by:
Hi all I m Using SQL SERVER 2005 I have a requirement to store some data in xmldatatype using stored procedure , Here is example
1
by: misogsk | last post by:
Hi. I need to create a new tableadapter retrieving data from DB using stored procedure. When i wrote stored procedure script in the stored procedure wizard and click next(or finish) it's generate an...
1
by: Fabio | last post by:
Hi, is there any method to call a store procedure into a function? Thanks Fabio
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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,...

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.