473,721 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL insert error

Dear All

I am trying to execute following cod

Sub SubmitBtn_Click (ByVal Sender As Object, ByVal E As EventArgs
Dim DBConn As OleDbConnectio
Dim DBInsert As New OleDbComman
DBConn = New OleDbConnection ("PROVIDER="
& "Microsoft.Jet. OLEDB.4.0;"
& "DATA SOURCE="
& Server.MapPath( "Emps.mdb;" )
DBInsert.Comman dText = "Insert Into Employees "
& "(LastName, FirstName, PhoneNumber, EmailAddress, "
& "Notes, DepartmentID) values ("
& "'" & Replace(txtLast Name.Text, "'", "''") & "', "
& "'" & Replace(txtFirs tName.Text, "'", "''") & "', "
& "'" & Replace(txtPhon eNumber.Text, "'", "''") & "', "
& "'" & Replace(txtEmai lAddress.Text, "'", "''")
& "', "
& "'" & Replace(txtNote s.Text, "'", "''") & "', "
& ddlDepartments. SelectedItem.Va lue & ")
DBInsert.Connec tion = DBCon
DBInsert.Connec tion.Open(
DBInsert.Execut eNonQuery(
Response.Redire ct("./index.aspx"
End Su

while executing following
DBInsert.Execut eNonQuery(

query i
Insert Into Employees (LastName, FirstName, PhoneNumber, EmailAddress, Notes, DepartmentID) values ('asdfas', 'asdf', 'asdfasfdasdf', 'asf', 'asdfasdf', 3

I get an error saying as follows, Whats happening... it's new to me.. more to that its an example striaght copy paste from one book
Operation must use an updateable query.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on: Operation must use an updateable query

Source Error:

Line 58: DBInsert.Connec tion = DBCon
Line 59: DBInsert.Connec tion.Open(
Line 60: DBInsert.Execut eNonQuery(
Line 61: Response.Redire ct("./index.aspx"
Line 62: End Su
Source File: c:\inetpub\wwwr oot\WebApplicat ion1\add1.aspx. vb Line: 60

Stack Trace:

[OleDbException (0x80004005): Operation must use an updateable query.
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(Int32 hr
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S dbParams, Object& executeResult
System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object& executeResult
System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r behavior, Object& executeResult
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior behavior, String method
System.Data.Ole Db.OleDbCommand .ExecuteNonQuer y(
WebApplication1 .add1.SubmitBtn _Click(Object Sender, EventArgs E) in c:\inetpub\wwwr oot\WebApplicat ion1\add1.aspx. vb:6
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler sourceControl, String eventArgument
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData
System.Web.UI.P age.ProcessRequ estMain(

Nov 18 '05 #1
3 1591
Hi Pravin

I've recreated the table in SQL Server 2000 using varchar(50) for all fields
but DepartmentID for which I used int.
I had no problem running the Query in SQL Analyzer. However, you might want
to check your table keys. I had a similar odd problem before and it turned
out to be caused by an misdefined primary key.

Martin
"Pravin A. Sable" <my***********@ ccs.neu.edu> wrote in message
news:5B******** *************** ***********@mic rosoft.com...
Dear All,

I am trying to execute following code

Sub SubmitBtn_Click (ByVal Sender As Object, ByVal E As EventArgs)
Dim DBConn As OleDbConnection
Dim DBInsert As New OleDbCommand
DBConn = New OleDbConnection ("PROVIDER=" _
& "Microsoft.Jet. OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath( "Emps.mdb;" ))
DBInsert.Comman dText = "Insert Into Employees " _
& "(LastName, FirstName, PhoneNumber, EmailAddress, " _
& "Notes, DepartmentID) values (" _
& "'" & Replace(txtLast Name.Text, "'", "''") & "', " _
& "'" & Replace(txtFirs tName.Text, "'", "''") & "', " _
& "'" & Replace(txtPhon eNumber.Text, "'", "''") & "', " _
& "'" & Replace(txtEmai lAddress.Text, "'", "''") _
& "', " _
& "'" & Replace(txtNote s.Text, "'", "''") & "', " _
& ddlDepartments. SelectedItem.Va lue & ")"
DBInsert.Connec tion = DBConn
DBInsert.Connec tion.Open()
DBInsert.Execut eNonQuery()
Response.Redire ct("./index.aspx")
End Sub

while executing following
DBInsert.Execut eNonQuery()

query is
Insert Into Employees (LastName, FirstName, PhoneNumber, EmailAddress, Notes, DepartmentID) values ('asdfas', 'asdf', 'asdfasfdasdf', 'asf',
'asdfasdf', 3)

I get an error saying as follows, Whats happening... it's new to me.. more to that its an example striaght copy paste from one book.
Operation must use an updateable query.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Data.Ole Db.OleDbExcepti on: Operation must use an updateable query.
Source Error:
Line 58: DBInsert.Connec tion = DBConn
Line 59: DBInsert.Connec tion.Open()
Line 60: DBInsert.Execut eNonQuery()
Line 61: Response.Redire ct("./index.aspx")
Line 62: End Sub
Source File: c:\inetpub\wwwr oot\WebApplicat ion1\add1.aspx. vb Line: 60

Stack Trace:
[OleDbException (0x80004005): Operation must use an updateable query.]
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(Int32 hr) System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S
dbParams, Object& executeResult) System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object& executeResult) System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r behavior, Object& executeResult) System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior behavior, String method) System.Data.Ole Db.OleDbCommand .ExecuteNonQuer y()
WebApplication1 .add1.SubmitBtn _Click(Object Sender, EventArgs E) in c:\inetpub\wwwr oot\WebApplicat ion1\add1.aspx. vb:60 System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP o
stBackEvent(Str ing eventArgument) System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler sourceControl, String eventArgument) System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain()

Nov 18 '05 #2
WJ
Trap the Exception.Messa ge (try{}catch{Exc eption: e}) or turn on Debug/Trace
to find the exact line that is broken. Normally, a table must also be
existed and opened successfully before any maintenance operations
(add/chg/del) can be performed. The exception message would give you
specific error.

John
Nov 18 '05 #3
Hi Martin,

Sorry for not specifying problem completely, I am getting careless after
coming to academics again.

The database is simple access xp database. I did some search on google
and found that, this error is due to privileges of machinename/ASP.net
user. I gave ASP.net user administrative privileges but yet no change.
In IIS I gave read, write, permission for this database file, but no
change. I am kind of stuck. Definitely this error has to do something
with Access and file permission but I am not sure how to solve them.

Best Regards,
Pravin

Martin Feuersteiner wrote:
Hi Pravin

I've recreated the table in SQL Server 2000 using varchar(50) for all fields
but DepartmentID for which I used int.
I had no problem running the Query in SQL Analyzer. However, you might want
to check your table keys. I had a similar odd problem before and it turned
out to be caused by an misdefined primary key.

Martin
"Pravin A. Sable" <my***********@ ccs.neu.edu> wrote in message
news:5B******** *************** ***********@mic rosoft.com...
Dear All,

I am trying to execute following code

Sub SubmitBtn_Click (ByVal Sender As Object, ByVal E As EventArgs)
Dim DBConn As OleDbConnection
Dim DBInsert As New OleDbCommand
DBConn = New OleDbConnection ("PROVIDER=" _
& "Microsoft.Jet. OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath( "Emps.mdb;" ))
DBInsert.Comman dText = "Insert Into Employees " _
& "(LastName, FirstName, PhoneNumber, EmailAddress, " _
& "Notes, DepartmentID) values (" _
& "'" & Replace(txtLast Name.Text, "'", "''") & "', " _
& "'" & Replace(txtFirs tName.Text, "'", "''") & "', " _
& "'" & Replace(txtPhon eNumber.Text, "'", "''") & "', " _
& "'" & Replace(txtEmai lAddress.Text, "'", "''") _
& "', " _
& "'" & Replace(txtNote s.Text, "'", "''") & "', " _
& ddlDepartments. SelectedItem.Va lue & ")"
DBInsert.Connec tion = DBConn
DBInsert.Connec tion.Open()
DBInsert.Execut eNonQuery()
Response.Redire ct("./index.aspx")
End Sub

while executing following
DBInsert.Execut eNonQuery()

query is
Insert Into Employees (LastName, FirstName, PhoneNumber, EmailAddress,


Notes, DepartmentID) values ('asdfas', 'asdf', 'asdfasfdasdf', 'asf',
'asdfasdf', 3)

I get an error saying as follows, Whats happening... it's new to me.. more


to that its an example striaght copy paste from one book.


Operation must use an updateable query.
Description : An unhandled exception occurred during the execution of the


current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Data.Ole Db.OleDbExcepti on: Operation must use an


updateable query.
Source Error:
Line 58: DBInsert.Connec tion = DBConn
Line 59: DBInsert.Connec tion.Open()
Line 60: DBInsert.Execut eNonQuery()
Line 61: Response.Redire ct("./index.aspx")
Line 62: End Sub
Source File: c:\inetpub\wwwr oot\WebApplicat ion1\add1.aspx. vb Line: 60

Stack Trace:
[OleDbException (0x80004005): Operation must use an updateable query.]
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(Int32


hr)

System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S
dbParams, Object& executeResult)
System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object&


executeResult)
System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r behavior,


Object& executeResult)
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior


behavior, String method)
System.Data.Ole Db.OleDbCommand .ExecuteNonQuer y()
WebApplication1 .add1.SubmitBtn _Click(Object Sender, EventArgs E) in


c:\inetpub\wwwr oot\WebApplicat ion1\add1.aspx. vb:60
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)


System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP o
stBackEvent(Str ing eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler


sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain()


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
7387
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great atmosphere. Good food.", " (Harry Houdini - 03/01/2004)"); INSERT INTO `reviews` VALUES("", "Le Chow Place", "Lunch", "yada yada", " (Herbert Hoover - 03/03/2004)"); INSERT INTO `reviews` VALUES("", "Golden Dragon", "Lunch", "Exquisite.
7
12126
by: iqbal | last post by:
Hi all, We have an application through which we are bulk inserting rows into a view. The definition of the view is such that it selects columns from a table on a remote server. I have added the servers using sp_addlinkedserver on both database servers. When I call the Commit API of oledb I get the following error: Error state: 1, Severity: 19, Server: TST-PROC22, Line#: 1, msg:
16
17012
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then IF FOUND UPDATE <TABLE> SET .... <Values entered here> ELSE INSERT INTO <TABLE> VALUES <Values...
6
4708
by: harborboy76 | last post by:
Hi, I am trying to insert a large number of rows into a table inside a SPL. But every time, I run the SPL, the table is locked because of the INSERT. When I tried to issue a COMMIT, right after the INSERT in the SPL. I got an error stating that there was no open cursor. I have done some research on here and found that it's not possible to issue a COMMIT inside an SPL. But it can be done so on the client side. Can anyone shade me some...
8
2043
by: 73blazer | last post by:
Hello, I'm looking for a way to make some of my insert templates more readable by placing comments in between the values. I cannot seem to find a way to do this with DB2, is there a way? I'm probably missing something basic. I have insert into ken.snyder id1,id2,id3 values (
3
2309
by: MP | last post by:
Hi Posted this several hours ago to another ng but it never showed up thought i'd try here. using vb6, ado, .mdb, jet4.0, no access given table tblJob with field JobNumber text(10) 'The example I had to go by 'INSERT INTO tblCustomers (CustomerID, , )
3
5157
by: mahajanvit | last post by:
Hi one and all I got this problem during my project. So in order to solve this I made a very small application. I am trying to insert using SP and sqldatasource control. I know that while using sqldatasource control, there is no need of opening and closing a connection. Also there is no need to write connection string. When i am selecting table from sqldatasource and writing insert statement in C# code, its working fine. When I am...
9
3699
by: anachronic_individual | last post by:
Hi all, Is there a standard library function to insert an array of characters at a particular point in a text stream without overwriting the existing content, such that the following data in appropriately moved further down? From a cursory search of the libc documentation I can't find such a function. Will I have to write it myself? Thanks.
2
4814
by: technocraze | last post by:
Hi guys, I have encountered this error when updating the values to the MS Acess table. Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and sql server is my backend server. This error occured whenever i step through and when it reaches rs.update it jux hangs down there and thereafter it shwn the aforementioned error. I am using the RecordSet properties to add the values. Can I use...
6
3465
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am using MS-Access 2000 database table for this app. Note that the datatype of all the fields mentioned above are Text. Apart from the above columns, there's another column in the DB table named 'RegDateTime' whose datatype is Date/Time which is...
0
8730
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9064
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8007
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.