Wrox Programmer Forums
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 8th, 2006, 03:16 AM
Authorized User
Join Date: Oct 2006
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts

Hi All,

Im new to asp.net programming and Im trying to write a simple program to udpate a database using microsoft access. I have consulted different books, and tried different solutions, but I always encounter this error.. "OPERATION MUST USE UPDATABLE QUERY".

Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
  "Data Source=C:\microcell.mdb"
  Dim dbConnection As New OleDbConnection(connectionString)


       Dim commandString As String = "INSERT INTO Employees(FirstName, LastName) " & _
 "Values(@FirstName, @LastName)"

        Dim dbCommand As New OleDbCommand(commandString, dbConnection)
        Dim firstNameParam As New OleDbParameter("@FirstName", OleDbType.VarChar, 10)
        firstNameParam.Value = txtfirstname.Text
        Dim lastNameParam As New OleDbParameter("@LastName", OleDbType.VarChar, 20)
        lastNameParam.Value = txtlastname.Text


Old October 8th, 2006, 10:01 AM
Wrox Author
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

IMHO, I hate paramertized queries because you can only use them for a specific task, in this case inserting a firstname and lastname into a database. What I do in all of my applications is I write a wrapper class that handles all of my database connectivity for ANY sql statement that I pass in (usually I just call a stored procedure). In any case something like this may work for you.

private SqlDataAdapter daSql;
private SqlCommand sqlCmd;
private sqlDataReader sqlDataReader;
private SqlConnection sqlConn;

public void writeUpdate(string strSQLcmd)
 sqlConn = new SqlConnection();
 sqlConn.ConnectionString = <connection string>
 sqlCmd = new SqlCommand(strSQLcmd, sqlConn);
 sqlCmd.CommandTimeout = 3800;
 sqlDataReader = sqlCmd.ExecuteReader();
 sqlDataReader = null;
 sqlConn = null;

That method is designed to handle queries that dont return a result set (eg UPDATE, DELETE or INSERT statements) what you would do in code is this

string sSQL;
sSQL = "INSERT INTO table(value1)values(somevalue)";

Of course you will need to change your object to OLEDB objects but the general idea is still the same.


--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
Old June 19th, 2007, 09:10 AM
Friend of Wrox
Join Date: Oct 2006
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts

... I am getting the same problem when executing a simple update query from Access VBA and am also struggling to locate the solution. In my code, the query is executed direct (and not parameterized).

UPDATE utility set appversion = '5.10.46'

Any ideas?


Sean Anderson

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access database through oledb commands castor C# 1 April 26th, 2007 12:27 PM
Error with ASP.NET opening OleDb/ODBC database gdelia1 ADO.NET 6 October 5th, 2005 01:50 AM
Help for Updating the database bspradeep Classic ASP Databases 1 May 10th, 2005 03:13 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.