插入访问数据库成功执行,但表中的数据未显示

时间:2014-08-24 19:21:50

标签: ms-access c#-4.0

OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;" +
                                            "Data Source=" + path + 
                                            "Persist Security Info=True");

OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into Customer ( CustFName, CustLName, Address, Gender, Email, Phone, Organization) values ('" + fname_AC.Text + "','" + lname_AC.Text + "','" + address_AC.Text + "','" + gen_AC.Text +"','" + email_AC.Text + "','" + ph_AC.Text + "','" + org_AC.Text + "')";
conn.Open();
try
{
    cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
    ex.Message.ToString();
}
finally
{
    conn.Close();
    cmd.Dispose();
}

1 个答案:

答案 0 :(得分:0)

实际上正在更新的数据库位于bin文件夹中,我正在检查的数据库位于项目文件夹中