【问题标题】:ADODB Error inserting to Access DB with JavaScript使用 JavaScript 插入 Access DB 时出现 ADODB 错误
【发布时间】:2015-08-10 19:28:45
【问题描述】:

我正在编写一个 .asp 文件以使用以下 JS 将数据插入 Access 数据库:

    MM_query =  "INSERT " + 
                "INTO Employees (FirstName, Surname, Department, Email, FaxNumber, JobTitle, KnownAs, MobileTelephone, WorkTelephone, MUGSHOT, WorkExtension, UseInPhoneWeb, Staff, Office, MobileSpeedDial, CompanyID1) " +
                "VALUES (\"" + textFirstname + "\", \"" + textSurname + "\", \"" + selectDept + "\", \"" + textemailAddress + "\", \"" + textFaxTel + "\", \"" + textJobTitle + "\", \"" + textAKA + "\", \"" + textMobile + "\", \"" + textWorkNo + "\", \"" + selectMugShot + "\", \"" + textExtn + "\", 1, 1, \"" + selectOffice + "\", " + textMobSpDial + ", " + selectCompany + ")";

    var conn = Server.CreateObject("ADODB.Connection");
    conn.Open(MM_PhoneWeb_conn_STRING);

    var rs = Server.CreateObject("ADODB.Recordset");
    rs.Open(MM_query, conn);

    conn.Close();

执行时出现以下错误:

An error occurred on the server when processing the URL. Please contact the system administrator. 

查询直接粘贴到访问时有效,类似的代码适用于从数据库中检索数据。

谁能建议如何最好地进行故障排除?

【问题讨论】:

  • 我猜你需要在值周围加上单引号。
  • 感谢 Mairaj,我最初尝试过,但后来将其更改为双引号。
  • 如果它是文本框,那么 textFirstname 看起来也是文本框的名称,而不是您需要获取此文本,例如 textFirstname.Text
  • 不,它们是参数... textFirstname = Request.QueryString("textFirstname");
  • 你能说出详细的错误吗?

标签: javascript asp.net ado adodb


【解决方案1】:

IIS 用于插入数据库的帐户对包含的文件夹/DB 具有只读权限。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 2014-05-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多