C# 如何将数据库中的多个数据存储在同一文本框中?C
您好,谢谢查看我的问题!我在从数据库中获取多个数据时遇到了一些问题。我试图在一个文本框中显示多个数据,当然,它不允许我这样做 我的代码: 第一预设;获取它找到的第一个数据,但我需要所有数据。我将如何制作它,以便它将显示多个数据而不是一个?谢谢大家 e、 g.文本框: 您的假期请求+getrecordd.Datefrom+-+getrecordd.Dateto+已发送。正在等待经理授权C# 如何将数据库中的多个数据存储在同一文本框中?C,c#,sql,database,forms,textbox,C#,Sql,Database,Forms,Textbox,您好,谢谢查看我的问题!我在从数据库中获取多个数据时遇到了一些问题。我试图在一个文本框中显示多个数据,当然,它不允许我这样做 我的代码: 第一预设;获取它找到的第一个数据,但我需要所有数据。我将如何制作它,以便它将显示多个数据而不是一个?谢谢大家 e、 g.文本框: 您的假期请求+getrecordd.Datefrom+-+getrecordd.Dateto+已发送。正在等待经理授权 您的假日请求+getrecordd.Datefrom+-+getrecordd.Dateto+已被授权。您可以获
您的假日请求+getrecordd.Datefrom+-+getrecordd.Dateto+已被授权。您可以获取所有记录,然后使用foreach 或者使用ForEach方法
您需要将所有值连接到单个字符串,以便在文本框中使用它。你认为结果应该是什么样的?
string authorised = "notReviewed";
SundownDatabaseEntities5 dbb = new SundownDatabaseEntities5();
System.Windows.Forms.Form ff = System.Windows.Forms.Application.OpenForms["Login"];
int idd = Convert.ToInt32(((Login)ff).idTb.Text);
var getrecordd = dbb.Holidays.Where(a => a.Id == idd).SingleOrDefault();
if (getrecordd.Authorised == authorised)
{
holidaysAuthorisedTb.Text = "Your holiday request (" + getrecordd.Datefrom + " - "+getrecordd.Dateto+") has been sent. Waiting for manager to authorise it...";
}
var getrecordds = dbb.Holidays.Where(a => a.Id == idd).ToList();
foreach (var getrecordd in getrecordds)
{
if (getrecordd.Authorised == authorised)
{
holidaysAuthorisedTb.Text += "Your holiday request (" + getrecordd.Datefrom + " - "+getrecordd.Dateto+") has been sent. Waiting for manager to authorise it...";
}
else
{
holidaysAuthorisedTb.Text += "Your holiday request (" + getrecordd.Datefrom + " - "+getrecordd.Dateto+") has been sent. Waiting for manager to authorise it..."
}
}
dbb.Holidays.Where(a => a.Id == idd).ForEach ( x =>
{
if (x.Authorised == authorised)
{
holidaysAuthorisedTb.Text += "Your holiday request (" + x.Datefrom + " - "+x.Dateto+") has been sent. Waiting for manager to authorise it...";
}
else
{
holidaysAuthorisedTb.Text += "Your holiday request (" + x.Datefrom + " - "+x.Dateto+") has been sent. Waiting for manager to authorise it..."
}
});