该行在
reader.Read()您的代码中丢失。您应该添加它。它实际上是从数据库读取数据的功能:
string conString = "Data Source=localhost;Initial Catalog=LoginScreen;Integrated Security=True";SqlConnection con = new SqlConnection(conString);string selectSql = "select * from Pending_Tasks";SqlCommand com = new SqlCommand(selectSql, con);try{ con.Open(); using (SqlDataReader read = cmd.ExecuteReader()) { while(reader.Read()) { CustID.Text = (read["Customer_ID"].ToString()); CustName.Text = (read["Customer_Name"].ToString()); Add1.Text = (read["Address_1"].ToString()); Add2.Text = (read["Address_2"].ToString()); PostBox.Text = (read["Postpre"].ToString()); PassBox.Text = (read["Password"].ToString()); DatBox.Text = (read["Data_important"].ToString()); LanNumb.Text = (read["Landline"].ToString()); MobNumber.Text = (read["Mobile"].ToString()); FaultRep.Text = (read["Fault_Report"].ToString()); } }}finally{ con.Close();}编辑:
假设您想将最后一条记录写入文本框,此代码将起作用。如果要应用不同的方案,例如单击
Next按钮时从数据库读取所有记录并更改texbox中的数据,则应创建并使用自己的模型,也可以将数据存储在DataTable和如果需要,请稍后再参考。



