程序中修改dataset表中的值(不返回数据库)
有时候,dataset从数据库中取到的值,我们需要根据实际情况,做些修改,然后呈现出来,但是,我们只是需要看到修改过的值,并不希望所做的修改,返回到数据库。
举个例子,数据库有字段“JCSB”、“CJCC”、“SJCYMJ”、“HSXS”,“JCSB”数据库字段为空,因为需要在程序中确定;“SJCYMJ”、“HSXS”字段都为固定值,然后用程序判断CJCC的值,对前两项做修改。
代码
 1        // 更改dataset中相关的数据
2 for (int i = 0; i < myDs.Tables["table_hntky"].Rows.Count;i++ )
3 {
4 myDs.Tables["table_hntky"].Rows[i]["JCSB"] = lbl_JCSB.Text;
5
6 if (myDs.Tables["table_hntky"].Rows[i]["CJCC"].ToString() == "100×100×100")
7 {
8 myDs.Tables["table_hntky"].Rows[i]["SJCYMJ"] = 10000;
9 myDs.Tables["table_hntky"].Rows[i]["HSXS"] = 0.95;
10 }
11 }
2 for (int i = 0; i < myDs.Tables["table_hntky"].Rows.Count;i++ )
3 {
4 myDs.Tables["table_hntky"].Rows[i]["JCSB"] = lbl_JCSB.Text;
5
6 if (myDs.Tables["table_hntky"].Rows[i]["CJCC"].ToString() == "100×100×100")
7 {
8 myDs.Tables["table_hntky"].Rows[i]["SJCYMJ"] = 10000;
9 myDs.Tables["table_hntky"].Rows[i]["HSXS"] = 0.95;
10 }
11 }
                    
                
                
            
        
浙公网安备 33010602011771号