下面附代碼,代碼工作正常,但它不是插入的價值觀,到我已經創建了訪問數據庫表,無論是代碼顯示任何錯誤使用C#插入數據訪問,淨
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void submit_Click(object sender, EventArgs e)
{
OleDbConnection cnon = new OleDbConnection();
cnon.ConnectionString [email protected]"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\visual_c\Database71.accdb";
OleDbCommand command = new OleDbCommand();
command.CommandText = "INSERT INTO electricity (Asset_name,Asset_number)VALUES('" + textBox1.Text + "','" + textBox2.Text + "')";
cnon.Open();
command.Connection = cnon;
command.ExecuteNonQuery();
cnon.Close();
}
}
}
是提交按鈕的事件hanlder連接到submit_Click? – Jade