使用Access插入INTO无效,没有任何错误?

时间:2018-12-06 00:16:29

标签: c# sql access

试图在Windows窗体(C#)上对ACCESS数据库进行INSERT INTO操作,这不会给我任何错误。

连接代码:

public Connection()
    {
        string path = AppDomain.CurrentDomain.BaseDirectory;
        AppDomain.CurrentDomain.SetData("DataDirectory", path);
        string connString = "provider='Microsoft.jet.OleDb.4.0'; data source='|DataDirectory|\\App_Data\\maple_data.mdb'";
        this.con = new OleDbConnection(connString);
    }

INSERT INTO代码:

Connection c = new Connection();
                c.conOpen();
                OleDbCommand cm = new OleDbCommand();
                cm.Connection = c.Con;
                cm.CommandText = "INSERT INTO bot ([keystroke], [timer], [position]) VALUES (@key, @spamTime, 1)";
                cm.Parameters.AddWithValue("@key", Key.Text);
                cm.Parameters.AddWithValue("@spamTime", spamTime);
                cm.ExecuteNonQuery();
                c.conClose();
                MessageBox.Show("Key as been added.");

谢谢。

0 个答案:

没有答案