如何使用Asp.Net C#添加数据 [英] How Can I Add Data Using Asp.Net C#
问题描述
任何人都可以告诉我添加数据的逻辑/代码。
i有一个数据库,数据将在日期输入,我必须按日期查看数据的添加。
就像我有一个销售数据库,其中产品是明确列出的,我必须明智地获得总销售日期。我混淆了如何去做,我在网格视图中显示数据。亲切地告诉我如何去做,如果可能的话,给我数据库查询来完成这项工作。
很多你的快速回答。
SqlConnection con = new SqlConnection(Data Source = SHANTANU \\SQLEXPRESS; Initial Catalog = ankur; Integrated Security = True);
con.Open();
string query =insert into Packing(Denier,Shade,Shade_No,Box_No,Lot_No,Gross_Wt,Tare_Wt,Net_Wt,No_Of_Cones,Packed_By)值('+ TextBox15.Text +','+ TextBox13.Text +',' + TextBox14.Text +','+ TextBox23.Text +','+ TextBox11.Text +','+ TextBox17.Text +','+ TextBox19.Text +',' + TextBox20.Text +','+ TextBox16.Text +','+ TextBox21.Text +');
SqlCommand cmd =新的SqlCommand(查询,骗局);
cmd.ExecuteNonQuery();
这里的箱号将提供数据日期明智,我想添加gross_wt日期明智的。
喜欢我f一些产品在4/1/14生产了200绿色,300蓝色等产品。
同样生产300绿色,400蓝色在5/1/14。
i想要当用户选择4/1/14时结果应该显示500
类似于选择5/1/14结果应该是700
< blockquote>我可以告诉你如何做到这一点。
你使用SQL SUM
[ ^ ]功能分组依据
条款。
因此,您需要通过分组您的日期列
来SUM Gross_Wt
。
我可以给出一个虚拟查询,但你只需相应修改。
SELECT yourDateColumn,SUM(Gross_Wt)
FROM
包装
WHERE yourDateColumn = someInputDate
GROUP BY yourDateColumn
can anyone tell me the logic/code to add data.
i have a database where data will be entered date wise and i have to see the addition of the data as per as date wise.
like i have a data base of sale where product is listed date wise and i have to get the Total sale date wise. i m confuse how to go for it,i am displaying the data in grid view. so kindly give me idea how to go for it and if possible give me the database query to get this job done.
txs a lot for your quick answer.
SqlConnection con = new SqlConnection("Data Source=SHANTANU\\SQLEXPRESS;Initial Catalog=ankur;Integrated Security=True");
con.Open();
string query = "insert into Packing(Denier,Shade,Shade_No,Box_No,Lot_No,Gross_Wt,Tare_Wt,Net_Wt,No_Of_Cones,Packed_By) values('" + TextBox15.Text + "','" + TextBox13.Text + "','" + TextBox14.Text + "','" + TextBox23.Text + "','" + TextBox11.Text + "','" + TextBox17.Text + "','" + TextBox19.Text + "','" + TextBox20.Text + "','" + TextBox16.Text + "','" + TextBox21.Text + "')";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
here the box number will feed the data "date wise" and i want to add the gross_wt date wise.
like if some product has production of like 200 green,300 blue etc on 4/1/14
similarly production of 300 green,400 blue on 5/1/14.
i want when user select 4/1/14 the result should show 500
similarly on selection of 5/1/14 result should be 700
I can give you the idea how to do it.
You have use SQLSUM
[^] function withGroup By
Clause.
So, you need to SUMGross_Wt
by GroupingYour Date Column
.
I can give a dummy query, but you just modify accordingly.
SELECT yourDateColumn, SUM(Gross_Wt) FROM Packing WHERE yourDateColumn = someInputDate GROUP BY yourDateColumn
这篇关于如何使用Asp.Net C#添加数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!