In asp.net, how to extract the value of each column of a row of data queried from the database?

SqlConnection con = new SqlConnection(@“server=.\sqlexpress;database=TestDataBase;uid=sa;pwd=123”);
con.Open();
SqlCommand cmd = new SqlCommand(“select * from Test1”, con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds); For
example, your sql statement is like this
ds.Table[0] is the table data you queried
ds.Table[0 ].Rows[0] is the first row
ds.Table[0].Rows[0][0] is the value of the first row and first column
ds.Table[0].Rows[1][2] is the second The value in the third column of the row

Guess you like

Origin blog.csdn.net/qq_41661800/article/details/106048292