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.OleDb;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private OleDbConnection connection = new OleDbConnection();
public Form1()
{
InitializeComponent();
connection = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\student\Downloads\WindowsFormsApplication14\WindowsFormsApplication14\bin\Debug\Database22.accdb");
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
connection.Open();
OleDbCommand command2 = new OleDbCommand();
command2.Connection = connection;
command2.CommandText = "insert into 學生資料 (學生姓名,學生號碼,生日,性別)
values('" + textBox1.Text + "','" + textBox2.Text + "','" +
textBox3.Text + "','" + textBox4.Text + "')";
command2.ExecuteNonQuery();
connection.Close();
connection.Close();
}
}
}
沒有留言:
張貼留言