protected void init() { String userid=""; String submithomework_marks = ""; String answer = ""; String attachment = ""; String sql = "select * from submithomework where homeworkid='42' and userid='450222199410300311'"; //存入数据库 1.获取路径或者答案,填入 SqlConnection conn = dc.SQL_con(); SqlCommand command = new SqlCommand(sql, conn); //3.执行数据库查询获取返回值 conn.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { userid = reader["userid"].ToString(); submithomework_marks = reader["submithomework_marks"].ToString(); answer = reader["answer"].ToString(); attachment = reader["attachment"].ToString(); } if (userid != null || userid.Equals("")) { TextBox1.Text = answer; } Response.Write("userid:" + userid); }
某一列,某一字段