将三个gridview合并为一个。 这是第一个Gridview
ItemCode Itemname NewCode SellingPrice PurchasePrice MRP
1 Soap 1
2 Bag 2
3 Cycle 3
4 Scissors 4
5 Pen 5
这是第二次Gridview
ItemCode NewCode
1 55874
2 889746210
5 466897
这是第三次Gridview
ItemCode SellingPrice PurchasePrice MRP
1 25 20 25
2 150 130 150
3 7500 6500 7500
4 20 17 17
5 10 8 10
我希望使用上述值更新第一个gridview并将其保存到数据库中
ItemCode Itemname NewCode SellingPrice PurchasePrice MRP
1 Soap 55874 25 20 25
2 Bag 889746210 150 130 150
3 Cycle 3 7500 6500 7500
4 Scissors 4 20 17 17
5 Pen 466897 10 8 10
答案 0 :(得分:0)
尝试这样的事情:
SELECT
a.ItemCode,a.Itemname,a.NewCode,a.SellingPrice,a.PurchasePrice,a.MRP,
b.ItemCode,IFNULL(b.NewCode, a.NewCode) as NewCode,
c.ItemCode,c.SellingPrice,c.PurchasePrice,c.MRP
FROM First a
LEFT JOIN Second b
on a.ItemCode=b.ItemCode
LEFT JOIN Third c
on a.ItemCode=c.ItemCode
答案 1 :(得分:0)
这就是我要找的东西
string connectionstring = ConfigurationManager.ConnectionStrings["Dbconnection"].ConnectionString;
SqlConnection con = new SqlConnection(connectionstring);
con.Open();
SqlCommand cmd = new SqlCommand("select * from tbl_eon",con);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
SqlCommand cmd2 = new SqlCommand("Update tbl_All set NewCode='" + dt.Rows[i]["EanCode"].ToString() + "' where ItemCode='" + dt.Rows[i]["ItemCode"] + "'", con);
cmd2.ExecuteNonQuery();
}
}