2016-01-21 78 views
0
con.Open(); 

//loading the image table 
DataTable dt = new DataTable(); 
SqlDataAdapter da = new SqlDataAdapter("Select * from Employee_Reg_Form", con); 
da.Fill(dt); 

//create a new row that will be added 
DataRow r = dt.NewRow(); 

//specify the records to save 

//Employee Registeration Codes 
r[0] = EmpRegCodSNtbox.Text; 
r[1] = EmpRegCodtbox.Text; 

这是用于新的ROW插入。我需要你使用类似的代码,但更新整行数据? 请建议。更新查询在SQL表中更新行(行号明智),而不使用C#中的SET关键字?

+0

实体框架可以帮助你做到这一点 –

回答

0
int rowNumber = 10; //put here your code to select the desired record 
dt[rowNumber][0] = EmpRegCodSNtbox.Text; 
dt[rowNumber][1] = EmpRegCodtbox.Text; 

不管怎样,在你的代码,你需要做的

dt.Rows.Add(r); 

dt.NewRow()只创建一个空行,但itn't连接到行集合。