c# - " formMain entry = new formMain(dt.Rows[0][0].ToString()); " What does this mean? Especially Rows[0][0] -


i'm newbie in programming world. given project , stuck database connectivity. thankful responses!

formmain entry = new formmain(dt.rows[0][0].tostring()); 

what mean? rows[0][0]?

please help.

dt object of datatable class (think of datatable normal database table), exposes property row of type datarow[] (a datarow array is), using can access single row of datatable passing row index; e.g. dt.rows[4] give 5th row of datatable.

a datarow object (think of datarow single row of data) in turn exposes own indexer of type object[] (an object array is), gives access individual values of columns of datarow. if datarow object named dr, can use dr[2] access or change value of 3rd column of dr. if want access or change value of 3rd column of 5th row, can this:

var dr = dt[4];  //5th row returned , stored in dr var myval = dr[2];  //value of dr's 3rd column stored in myval 

or can in 1 line:

var myval = dt[4][2]; 

which code doing, i.e. passing value of first column of first row of dt constructor of frmmain.

my suspicion datatable being used container of single value (an single integer, 1 string etc.), i.e. dt contains 1 row , row has 1 value in it, may id of something. if case, should better check code , see prepares , populates dt object. there better ways of accessing single values databases (google executescalar()), rid of creating datatable first , accessing rows , columns.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -