我正在尝试制作房间请求程序,并且需要连接到数据库的两个窗口(我知道该怎么做)。这两个窗口叫做EMERGENCY和JANITOR。我的问题是我不知道如何在数据库中存储信息。就像让我们说有人以紧急方式登录并发送请求一样,需要存储信息,一旦JANITOR登录,他就可以看到请求。到目前为止,我有数据库但不确定是否存储信息而不手动添加它们。如果有人有关于如何做到这一点的任何指南或链接,我会很感激!
紧急窗口代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace LOGINPAGE
{
public partial class EMERGENCY : Form
{
public EMERGENCY()
{
InitializeComponent();
}
void Fillcombo()
{
}
private void EMERGENCY_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'roomInfoDataSet6.Table' table. You can move, or remove it, as needed.
}
private void xButton1_Click(object sender, EventArgs e)
{
this.Close();
Application.Exit();
}
private void xButton2_Click(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Search_Click(object sender, EventArgs e)
{
}
}
}

JANITOR代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LOGINPAGE
{
public partial class JANITOR : Form
{
public JANITOR()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void JANITOR_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'roomInfoDataSet3.Table' table. You can move, or remove it, as needed.
this.tableTableAdapter.Fill(this.roomInfoDataSet3.Table);
}
private void xButton4_Click(object sender, EventArgs e)
{
}
private void xButton2_Click(object sender, EventArgs e)
{
this.Close();
Application.Exit();
}
}
}

答案 0 :(得分:0)
您可以使用Ms access db
你会发现通过大量的YouTube视频教程可以轻松地从c#连接到acess
我可以在它的数据库中有一个表,通过“保存紧急”按钮进行更新,并且看门人的加载紧急按钮将使用填充了第一个按钮的同一个表中的项目填充数据网格视图