所以我正在开发一个数据库程序,它需要使用 INSERT INTO 命令将日志插入数据库,但是执行查询后表仍然为空。请帮忙!谢谢~这是代码。
//Predefined connection string
OleDbConnection vcon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\xxx\Desktop\data.mdb;Jet OLEDB:Database Password=xxx;");
private void Login_Load(object sender, EventArgs e)
{
Log("StartUp", "System", "NULL", "System StartUp");
}
public void Log(string Type, string User, string Table_affected, string Remarks)
{
string NowDateStamp = string.Format("{0}/{1}/{2}",
DateTime.Now.Day.ToString(),
DateTime.Now.Month.ToString(),
DateTime.Now.Year.ToString());
string NowTimeStamp = string.Format("{0}:{1}:{2}",
DateTime.Now.Hour.ToString(),
DateTime.Now.Minute.ToString(),
DateTime.Now.Second.ToString());
string tempSQL = string.Format("INSERT INTO 'Log' VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')",
NowDateStamp,
NowTimeStamp,
Type,
User,
Table_affected,
Remarks);
vcon.Open();
OleDbCommand vcom = new OleDbCommand(tempSQL, vcon);
vcom.ExecuteNonQuery();
MessageBox.Show("Done"); // <-- This MessageBox isn't even showing.
vcon.Close();
}
所以基本上程序会启动然后记录时间,但是它似乎对数据库没有做任何事情,任何人都可以帮助我吗?谢谢!