troubleshooting Question

ExecuteNoQuery giving unspecified error

Avatar of shawnpbrady
shawnpbradyFlag for United States of America asked on
Microsoft AccessASP.NET
13 Comments1 Solution497 ViewsLast Modified:
Hello all,

I have an ASP.Net App the works perfectly in the developement environment, but when I publish it to my server and try to use it off of the server it works until I try to update the database.  The database is in access.  I get the following error "An unspecified error occured."  I have narrowed it down to a specific line of code that is causing the problem, when I ExecuteNonQuery.

Here is the code for the function:

            // Path on server
            string connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + AccessDBPath;
            // create database connection
            OleDbConnection dbconn = new OleDbConnection(connectionstring);

            string sqlcommand = "update Customers SET CompanyName='" + CompanyName + "',ContactFirstName='" + ContactFirstName +
                                "',ContactLastName='" + ContactLastName + "',CompanyOrDepartment='" + CompanyOrDepartment + "',BillingAddress='" + BillingAddress +
                                "',City='" + City + "',StateOrProvince='" + StateOrProvince + "',PostalCode='" + PostalCode + "',CountryRegion='" + CountryRegion +
                                "',ContactTitle='" + ContactTitle + "',PhoneNumber='" + PhoneNumber + "',Extension='" + Extension + "',FaxNumber='" + FaxNumber +
                                "',EmailAddress='" + EmailAddress + "',Notes='" + Notes + "',LabPCWired='" + LabPCWired + "',RegisteredModules='" + RegisteredModules +
                                "',UserDefinedRegistered='" + UserDefinedRegistered +
                                "' WHERE CustomerID=" + CustomerID;
            // 1. Instantiate a new command with a query and connection
            OleDbCommand cmd = new OleDbCommand(sqlcommand, dbconn);
            // 2. Call ExecuteNonQuery to send command
            cmd.ExecuteNonQuery();  // <--- !!! This is what is causing the error !!!
            // 4. close connection
            // return
            return true;
        catch (Exception ex)
            throw ex;
            return false;

Any help would be gratly appreciated.  I am thinking I have something configured incorrectly on the server or in my web.config file.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 13 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros