473,320 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

'Operation must be an updateable query'

OK Folks, its not very often that I ask a question, but I think I'm missing
something and I just cant seem to see it, Im very tired so some help would
be appreciated.

I have a webform with a DataGrid on it. In the DataGrid1.UpdateCommand, I am
setting a very simple update command

"UPDATE tblUsers SET FirstName='Manuel' WHERE UserID=1"

Now, I have tried the same technique from a windows forms application and
it works fine, why might I be getting this Exception
'Operation must be an updateable query'

When I execute the UpdateCommand.ExecuteNonQuery

I hate asking for help, but when your working on your own for hours on end,
sometimes it helps to talk to another !

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
Nov 20 '05 #1
6 1132
If executing against an Access database, perhaps a permissions error for the
ASP.NET user for the .mdb file? (I usually put access files in their own
subfolder and give ASP.NET modify rights to folder. That way the .ldb file
can be created)

Just a guess,
Greg

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:u1**************@TK2MSFTNGP12.phx.gbl...
OK Folks, its not very often that I ask a question, but I think I'm missing something and I just cant seem to see it, Im very tired so some help would
be appreciated.

I have a webform with a DataGrid on it. In the DataGrid1.UpdateCommand, I am setting a very simple update command

"UPDATE tblUsers SET FirstName='Manuel' WHERE UserID=1"

Now, I have tried the same technique from a windows forms application and
it works fine, why might I be getting this Exception
'Operation must be an updateable query'

When I execute the UpdateCommand.ExecuteNonQuery

I hate asking for help, but when your working on your own for hours on end, sometimes it helps to talk to another !

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

Nov 20 '05 #2
Maybe if you post the relevant code we will spot something there.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:u1**************@TK2MSFTNGP12.phx.gbl...
OK Folks, its not very often that I ask a question, but I think I'm missing something and I just cant seem to see it, Im very tired so some help would
be appreciated.

I have a webform with a DataGrid on it. In the DataGrid1.UpdateCommand, I am setting a very simple update command

"UPDATE tblUsers SET FirstName='Manuel' WHERE UserID=1"

Now, I have tried the same technique from a windows forms application and
it works fine, why might I be getting this Exception
'Operation must be an updateable query'

When I execute the UpdateCommand.ExecuteNonQuery

I hate asking for help, but when your working on your own for hours on end, sometimes it helps to talk to another !

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

Nov 20 '05 #3
Hi Terry,

I made a complete test with every on it even a datagrid, an insert, a
datareader and your update.
No problems at all even with exactly the same text as you.

So as Mariana said show some code, (when you want it, you see my email
adres, however tomorrow I have almost no time)

Cor
Nov 20 '05 #4
I'm givin up for tonight. . . Here's the code.

Cheers

Public Class WebForm1
Inherits System.Web.UI.Page

Private Con As New System.Data.OleDb.OleDbConnection("Data
Source=C:\ASPNET\Banking.mdb;Provider=Microsoft.Je t.OLEDB.4.0;")
Private SelectCommand As New System.Data.OleDb.OleDbCommand
Private UpdateCommand As New System.Data.OleDb.OleDbCommand
Private DS1 As New DS
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Private DA As New System.Data.OleDb.OleDbDataAdapter

Private Sub FillDataSet()

'Select Command
SelectCommand.CommandText = "SELECT * FROM tblUsers"
SelectCommand.Connection = Con

DA.SelectCommand = SelectCommand
DataGrid1.DataSource = DS1.Tables("tblUsers")

Try
Con.Open()
DS1.Clear()
DA.Fill(DS1, "tblUsers")
DataGrid1.DataBind()
Catch ex As Exception
Label1.Text = ex.Message
Finally
Con.Close()
End Try
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then Me.FillDataSet()

End Sub
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.EditCommand
Label1.Text = "Im in Edit"
Me.FillDataSet()
DataGrid1.EditItemIndex = e.Item.ItemIndex
DataGrid1.DataBind()

End Sub

Private Sub DataGrid1_DeleteCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.DeleteCommand
Label1.Text = "Im in Delete"
End Sub

Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.UpdateCommand
Label1.Text = "I'm In Update"

Dim UpdateCommand As New System.Data.OleDb.OleDbCommand
DA.UpdateCommand = UpdateCommand

Try
Con.Open()
UpdateCommand.Connection = Con
UpdateCommand.CommandText = "UPDATE tblUsers SET
FirstName='GARY' WHERE UserID=1"
'DA.Update(DS1, "tblUSers")

Label1.Text = UpdateCommand.ExecuteNonQuery
'^^^^^^^^ FAILS HERE ^^^^^^^^^^^
DataGrid1.EditItemIndex = -1
Me.FillDataSet()

'At End
'DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
Catch ex As Exception
Label1.Text = ex.Message
Finally
Con.Close()
End Try
End Sub
End Class
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Terry,

I made a complete test with every on it even a datagrid, an insert, a
datareader and your update.
No problems at all even with exactly the same text as you.

So as Mariana said show some code, (when you want it, you see my email
adres, however tomorrow I have almost no time)

Cor

Nov 20 '05 #5
I can't see anything obviously wrong, so I would then go with what Greg
suggested, which is that ASP.NET does not have sufficient rights to modify
that file. Make sure that it does.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:eb**************@TK2MSFTNGP12.phx.gbl...
I'm givin up for tonight. . . Here's the code.

Cheers

Public Class WebForm1
Inherits System.Web.UI.Page

Private Con As New System.Data.OleDb.OleDbConnection("Data
Source=C:\ASPNET\Banking.mdb;Provider=Microsoft.Je t.OLEDB.4.0;")
Private SelectCommand As New System.Data.OleDb.OleDbCommand
Private UpdateCommand As New System.Data.OleDb.OleDbCommand
Private DS1 As New DS
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Private DA As New System.Data.OleDb.OleDbDataAdapter

Private Sub FillDataSet()

'Select Command
SelectCommand.CommandText = "SELECT * FROM tblUsers"
SelectCommand.Connection = Con

DA.SelectCommand = SelectCommand
DataGrid1.DataSource = DS1.Tables("tblUsers")

Try
Con.Open()
DS1.Clear()
DA.Fill(DS1, "tblUsers")
DataGrid1.DataBind()
Catch ex As Exception
Label1.Text = ex.Message
Finally
Con.Close()
End Try
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then Me.FillDataSet()

End Sub
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.EditCommand
Label1.Text = "Im in Edit"
Me.FillDataSet()
DataGrid1.EditItemIndex = e.Item.ItemIndex
DataGrid1.DataBind()

End Sub

Private Sub DataGrid1_DeleteCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.DeleteCommand
Label1.Text = "Im in Delete"
End Sub

Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.UpdateCommand
Label1.Text = "I'm In Update"

Dim UpdateCommand As New System.Data.OleDb.OleDbCommand
DA.UpdateCommand = UpdateCommand

Try
Con.Open()
UpdateCommand.Connection = Con
UpdateCommand.CommandText = "UPDATE tblUsers SET
FirstName='GARY' WHERE UserID=1"
'DA.Update(DS1, "tblUSers")

Label1.Text = UpdateCommand.ExecuteNonQuery
'^^^^^^^^ FAILS HERE ^^^^^^^^^^^
DataGrid1.EditItemIndex = -1
Me.FillDataSet()

'At End
'DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
Catch ex As Exception
Label1.Text = ex.Message
Finally
Con.Close()
End Try
End Sub
End Class
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Terry,

I made a complete test with every on it even a datagrid, an insert, a
datareader and your update.
No problems at all even with exactly the same text as you.

So as Mariana said show some code, (when you want it, you see my email
adres, however tomorrow I have almost no time)

Cor


Nov 20 '05 #6
Yep, that was it. Permissions are a little bit more convoluted to do on XP
because by default simple file sharing is switched on.

Fixed - Thanks everyone

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:u1**************@TK2MSFTNGP12.phx.gbl...
OK Folks, its not very often that I ask a question, but I think I'm missing something and I just cant seem to see it, Im very tired so some help would
be appreciated.

I have a webform with a DataGrid on it. In the DataGrid1.UpdateCommand, I am setting a very simple update command

"UPDATE tblUsers SET FirstName='Manuel' WHERE UserID=1"

Now, I have tried the same technique from a windows forms application and
it works fine, why might I be getting this Exception
'Operation must be an updateable query'

When I execute the UpdateCommand.ExecuteNonQuery

I hate asking for help, but when your working on your own for hours on end, sometimes it helps to talk to another !

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

Nov 20 '05 #7

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

Similar topics

8
by: Tom wilson | last post by:
This is driving me nuts. I'm trying to update an Excel spreadsheet using ADO.Net and Oledb in VB.Net. The connection is open, the adapter is connected and the dataset is loaded. Here's the code...
6
by: ano1optimist | last post by:
I have been running these queries in Access 2000 with no problems. This week, I had to install Access 2003 to create some runtime versions for another application, and now I keep getting "operation...
4
by: MDW | last post by:
Hey all. I'm confused. I'm trying to add a single record into an Access 2000 database using ASP.Net. Here is the code: objConn = New OleDbConnection(strConnect) objConn.Open objCommand =...
606
by: Neil Zanella | last post by:
Hello, I am trying to update an MS access database from ASP.NET. I am using IIS on Windows XP Pro. I can issue SELECT statements from ASP.NET using ADO.NET but I cannot seem to be able to carry...
2
by: SheryMich | last post by:
Hi - I am having a bit of a problem with the insert into a database. When I go to insert a record into an un-keyed, single table Access database, I get the aforementioned ''Operation Must Use an...
8
by: Jim in Arizona | last post by:
I've been using an example out of a book to be able to edit the rows in a database. I am getting the following error: ========================================================...
1
by: Muskito | last post by:
HELP!!! Hello All, I'm using VB.net 2003 and trying to update data in Excel worksheet. The program selects data from the excel, updates something in the MSSQL DB and then tries to update...
11
by: Arpan | last post by:
I have always been working with SQL Server 2005 for ASP.NET apps but due to some reasons, had to revert back to MS-Access 2000. When I try to insert/update a MS-Access DB table (MDB), ASP.NET...
1
by: pavya | last post by:
Hi, I have developed one Web application. At that time my system had a FAT file system on it and this application worked properly. But now i have converted FAT file system to NTFS file system and...
0
by: rickmedlin | last post by:
I know this has been posted on elsewhere but I'm stuck. I'm using the following append query to copy an Access query to Excel: INSERT INTO . SELECT * FROM Test; This isn't the real table...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.