创建表等与名称StckDetails enter image description here
后创建具有ANME sp_StckDetails1 ALTER过程[DBO]过程。[sp_StockDetails1] (
@Action VARCHAR(20), @Branch_ID INT = NULL, @Stock_Name VARCHAR(50)=零, @Stock_code VARCHAR(20)=零, @Qty INT =无效, @Purchase_Price十进制(18,0)=零, @Sales_Price十进制(18,0)=空, @Order_ID int = null ) as BEGIN SET NOCOUNT ON; 如果@动作= '更新' 开始 更新StockDetails设定数量= @数量,Purchase_Price = @ Purchase_Price,Sales_price = @ Sales_Price其中Order_ID上= @ Order_ID上 端 结束
然后添加C#代码是 标签lbl_id = GridView2.Rows [e.RowIndex] .FindControl(“Label2”)作为Label; TextBox txt1_qty = GridView2.Rows [e.RowIndex] .FindControl(“TextBox7”)as TextBox; TextBox txt2_PP = GridView2.Rows [e.RowIndex] .FindControl(“TextBox8”)as TextBox; TextBox txt3_sp = GridView2.Rows [e.RowIndex]。FindControl(“TextBox9”)作为TextBox;
SqlCommand cmd = new SqlCommand("sp_StockDetails1", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Action", "Update");
cmd.Parameters.AddWithValue("@Order_ID", SqlDbType.Int).Value = Convert.ToInt32(lbl_id.Text);
cmd.Parameters.AddWithValue("@Qty", SqlDbType.Int).Value = Convert.ToInt32(txt1_qty.Text);
cmd.Parameters.AddWithValue("@Purchase_Price", SqlDbType.Decimal).Value = Convert.ToDecimal(txt2_PP.Text);
cmd.Parameters.AddWithValue("@Sales_Price", SqlDbType.Decimal).Value = Convert.ToDecimal(txt3_sp.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
GridView2.EditIndex = -1;
fillgrid2();
的GridView DESIN代码的aspx代码
'> '> “> '> '> '> '> '> '> '> ........................................ 。
尝试它,它就会字
我不认为一个存储过程固定的数据结构.... – user1612851 2013-03-20 21:56:15
它,在你不能轻易改变其结构或移动到另一个数据库中的意义发动机。 – 2013-03-20 21:57:24
在一个项目中完全改变数据库的可能性很小。你仍然需要更新你的对象。有些事情将不得不更新以更改数据库。我尝试尽可能简单地做到这一点,因为我是Web应用程序的新手。 – user1612851 2013-03-21 15:36:30