私は部屋のリクエストプログラムを作成しようとしており、データベースへの接続に必要な2つのウィンドウを持っています。 2つのウィンドウはEMERGENCYとJANITORと呼ばれます。私の問題は、データベースに情報を格納する方法がわかりません。誰かがEMERGENCYとしてログインしてリクエストを送信すると、その情報を保存する必要があり、JANITORがログインするとリクエストを見ることができます。これまではデータベースを持っていましたが、手動で追加することなく情報を格納することはできません。誰かがこれを行う方法に関するガイドやリンクを持っているなら、私はそれを感謝します!データベースに情報を保存し、GUIウィンドウに表示します。 (Visual Studios)
EMERGENCYウィンドウコード:
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 https:// w ww.youtube.com/watch?v=Z7713GBhi4k –
これは、必要なものよりも複雑です.... – Programmer23
逆のEntityフレームワーク、LinqのSQLは、開発者の生活をより簡単にするために構築されていると思います。他の賢い人は他のものを見つけることができますあなたの接続を管理するためにsqlConnectionと他のクラスを使用しているGoogleで、コードをコピーして実行していますが、プロの方法やそれを行う正しい方法ではありません。あなたが望むならDataSetを使用する方法を見ることができますが、私のアドバイスはあなたが選んだ方法(たくさんのコードを書く必要はありません)です。なぜなら、これはVisual Studioの役割だからです。 –