【发布时间】:2016-08-06 02:41:21
【问题描述】:
我正在尝试制作一个房间请求程序,并且有两个窗口需要连接到数据库(我知道该怎么做)。这两个窗口分别称为 EMERGENCY 和 JANITOR。我的问题是我不知道如何在数据库中存储信息。就像假设有人以 EMERGENCY 身份登录并发送请求,需要存储信息,一旦 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)
{
}
}
}
门卫代码:
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();
}
}
}
【问题讨论】:
-
你可以先学习Entity Framework的基础youtube.com/watch?v=Z7713GBhi4k
-
这比需要的太复杂了......
-
我认为恰恰相反,Entity framework ,Linq to SQL 的构建是为了让开发人员的生活更轻松,否则你可以使用 sqlConnection 和其他类在谷歌中找到其他东西来管理你的连接,你会复制并通过代码(哇它工作),但它不是专业的方式或正确的方式来做到这一点。如果您愿意,您可以查看如何使用 DataSet,但我建议您选择哪种方式(您不必编写太多代码),因为这是 Visual Studio 的角色,而不是我们,哈哈。
-
因为这是一个大学项目,我们只允许使用SqlConnection。如果您有任何使用 sql 的知识,我很乐意为您服务。谢谢
-
Em ,好吧,很酷,对不起,我不知道,看看这个链接也许它可以帮助你。dotnetdaily.net/tutorials/…
标签: c# sql visual-studio visual-studio-2012