Help with using stored procedures and sending data to sql.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello. Iam a beginner in programming so <span id="x_x_x_x_x_result_box" lang="en
<span title="Click for alternate translations do not judge <span title="Click for alternate translations
strictly. :)<br/>

For example: i have table wich has 3 columns (with data in it).
Code | Name | Price | UpdateButton (on Windows Form)
1 | Aaa | 10
2 | Bbb | 20
3 | Ccc | 30
Ive created next 2 Stored Procedures :
CREATE PROCEDURE dbo.GetByCode<br/>
<br/>
@code int<br/>
AS<br/>
SELECT Name, Price
FROM warehouse WHERE Code = @code
<br/>
RETURN

CREATE PROCEDURE dbo.UpdateByCode
@code int ,
@price int
AS<br/>
UPDATE TableName
SET price=@price WHERE Code = @code
<br/>
RETURN
Now what i am trying to do:))
In C# using event textchanged in CodeTextbox.Text, i want to call procedure GetByCode, sent value from CodeTextbox.Text to @code in this procedure and display selected datas (Name and Price) from sql (via this procedure and code) into Nametextbox.Text
, Pricetextbox.Text

After using event UpdateButton_click, i want to call procedure UpdateByCode, again sent value from CodeTextbox.Text to @code, PriceTextbox.Text to @price in this procedure and update column price row value where code = @code as said in Stored
Procedure :)

For Example. i wrote 2 into Codetextbox.text and via GetByCode procedure i filled Nametextbox.text with value Bbb and Pricetextbox.text with value 20,
after changing Pricetextbox.text value from 20 to 25, i click on UpdateButton call Stored Procedure UpdateByCode and i get next results :)

Code | Name | Price | UpdateButton (on Windows Form)
1 | Aaa | 10
2 | Bbb | 25
3 | Ccc | 30
Thanks for your patience.

View the full article
 
Back
Top