0

I have Website which works fine on localhost but not on server when uploaded, it is giving an error as Operation must use a updatable query

Code is as follows:

    OleDbConnection myCon;

    string path = @Server.MapPath(".") + "/Accomdation1.mdb";
    myCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path);

    myCon.Open();
    string f = TextBox1.Text;
    string g = TextBox5.Text;
    string d = DropDownList1.Text;
    string a = TextBox2.Text;
    string h = TextBox7.Text;
    string k = TextBox6.Text;
    string u = TextBox8.Text;
    string y = TextBox9.Text;

    OleDbCommand cmd = new OleDbCommand("INSERT INTO Accomdation (lastname, firstname,gender,UHCLID,Dateofarrival,timeofarrival,flightno,emaildi)" + " VALUES('" + f + "', '" + g + "', '" + d + "', '" + a + "', '" + h + "', '" + k + "', '" + u + "', '" + y + "')", myCon);
    cmd.ExecuteNonQuery();           
    // TextBox1.Text = e1.Message;     
    myCon.Close();
user1465978
  • 61
  • 2
  • 10
  • 3
    FYI, look into parameterized queries to protect yourself from SQL injection. – Anthony Pegram Jun 28 '12 at 02:19
  • Possible duplicate of: http://stackoverflow.com/questions/170578/operation-must-use-an-updatable-query-error-3073-microsoft-access – Alex R. Jun 28 '12 at 02:20
  • Ya i can do it later but first this is not excuting when uploaded into server – user1465978 Jun 28 '12 at 02:21
  • Please any one reply i am really stuck... – user1465978 Jun 28 '12 at 02:29
  • why are your variables semi obfuscated? it gets compiled no? – rlemon Jun 28 '12 at 03:11
  • possible duplicate of [Error: operation must use an updateable query](http://stackoverflow.com/questions/2749674/error-operation-must-use-an-updateable-query) – Fionnuala Jun 28 '12 at 09:57
  • Without much information, I'd say is a permissions problem on your db file, take a look at http://www.mikesdotnetting.com/Article/74/Solving-the-Operation-Must-Use-An-Updateable-Query-error – Jaime Jun 28 '12 at 02:43

1 Answers1

0

tyr the followings! 1. make sure you are not opening "Accomdation1.mdb" while trying to execute the above code. 2. right click App_folder under "Accomdation1.mdb" go to properties under the securiety tab give full permission to "NETWORK SERVICE"

mintokyo
  • 14
  • 4