0

I am writing an .asp file to insert data to an Access database using the following JS:

    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();

Upon execution I get the following error:

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

The query works when pasted directly to access and similar code works for retrieving data from the DB.

Can anyone suggest how best to troubleshoot?

Bailz
  • 605
  • 2
  • 8
  • 17
  • I guess you need to put single quotes around the values. – Mairaj Ahmad May 28 '15 at 10:35
  • Thanks Mairaj, I'd tried that initially but then later changed it to double quotes. – Bailz May 28 '15 at 10:44
  • Also textFirstname looks to be name of textbox if it is textbox than you need to get text of this like `textFirstname.Text` – Mairaj Ahmad May 28 '15 at 10:45
  • Nope, they're parameters... textFirstname = Request.QueryString("textFirstname"); – Bailz May 28 '15 at 10:50
  • Can u tell the detailed error ? – Mairaj Ahmad May 28 '15 at 10:52
  • Detailed errors are enabled but all I get is: An error occurred on the server when processing the URL. Please contact the system administrator. If you are the system administrator please click here to find out more about this error. – Bailz May 28 '15 at 10:53
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/78999/discussion-between-mairaj-ahmad-and-bailz). – Mairaj Ahmad May 28 '15 at 10:54
  • Why have you used slashes you can simply write the query like this `"INSERT " + "INTO Employees (FirstName, Surname, Department, Email, FaxNumber, JobTitle, KnownAs, MobileTelephone, WorkTelephone, MUGSHOT, WorkExtension, UseInPhoneWeb, Staff, Office, MobileSpeedDial, CompanyID1) " + "VALUES ('" + textFirstname + "', '" + textSurname + "',........." ` – Mairaj Ahmad May 28 '15 at 10:55

1 Answers1

0

The account used by IIS to insert to the database had read-only permissions on the containing folder/DB.

Bailz
  • 605
  • 2
  • 8
  • 17