【问题标题】:saving information in a database/displaying them in a GUI window. (Visual Studios)在数据库中保存信息/在 GUI 窗口中显示它们。 (视觉工作室)
【发布时间】: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();
        }
    }
}

EMERGENCY

JANITOR

【问题讨论】:

  • 你可以先学习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


【解决方案1】:

你可以使用ms访问db

通过大量 YouTube 视频教程,您会发现从 c# 连接到访问非常容易

我可以在它的数据库中有一个表,该表由“保存紧急”按钮更新,管理员的加载紧急按钮只会用第一个按钮填充的同一张表中的项目填充 datagridview

【讨论】:

  • 这可以满足我的需求。有关如何执行此操作的任何代码/示例?
  • 你可以从这里开始学习google.com.ng/url?q=http://m.youtube.com/…
  • 什么数据库类型?使用权? mysql?哪个版本?无论如何,您只需要一张桌子。给我数据库的详细信息,我将引导您完成整个过程。请接受答案。
  • 我在 Visual Studio 中使用本地数据库
  • 我不确定你在问什么。这是一个本地的sql数据库。
猜你喜欢
  • 2012-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-22
  • 1970-01-01
  • 2011-10-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多