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);
比如你的
sql语句是这样的
ds.Table[0]就是你查询到的表数据
ds.Table[0].Rows[0]就是第一行
ds.Table[0].Rows[0][0]就是第一行第一列的值
ds.Table[0].Rows[1][2]就是第二行第三列的值
。。后面的没问题了吧
追问这些我都知道
我的是:根据用户名查找显示
追答你如你的用户名字段为UserName
ds.Table[0].Rows[0][“UserName”]就可以了