我正在使用带有 C# 的 MS Access 数据库并创建一个 Web 服务。对于与数据库的连接,我使用以下代码
String databasePath = @"C:\inetpub\wwwroot\02 CustomerCreate\CustomerCreate\adResDemo.mdb";
String Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + databasePath + ";Persist Security Info=False";
//Connection to database
con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + databasePath + ";Persist Security Info=False");
con.Open();
现在我正在使用代码在表中插入一些行。我为此使用以下代码
//Query For ZipCode Insertion
String zipQuery = "INSERT INTO ZipCodes(ZipCode, City, State, DeliveryCharge, DeliveryComp, AutoID, RowGUID) VALUES ('" + PostCode + "','" + City + "','" + State + "'," + DeliveryCharge + "," + DeliveryComp + "," + AutoID + ",'" + RowGUIDZipCode + "')";
//Inserts query ZipCodes Table
cmd = new OleDbCommand(zipQuery, con);
cmd.ExecuteNonQuery();
现在,当我直接在 Visual Studio 上运行上面的代码时,它的工作正常并且数据库中的条目发生了。但是,当我在 IIS 服务器cmd.ExecuteNonQuery()上部署此 Web 服务时,会引发运行时异常并且它不会在数据库中插入任何值。
例外
System.Data.OleDb.OleDbException: Operation must use an updateable query.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at CustomerCreate.Service1.createCustomer(String FirstName, String LastName, String EmailAddress, String CompanyName, String StreetAddress, String PostCode, String City, String State, String Country, String PhoneNumber) in C:\inetpub\wwwroot\02 CustomerCreate\CustomerCreate\Service1.asmx.cs:line 141
这是什么类型的问题?